2017-11-02 18 views
0

セットからノードを削除するにはどうすればよいですか?セットからノードを削除する方法は?

たとえば、velociraptordinosから削除します。しかし、私がスクリプトを実行すると、dinos.map().val(cb)の実行後にはまだdinosの後ろに2つのノードがあります。

const Gun = require('gun');  
const gun = new Gun({ peers: [ 'https://localhost:8888/gun' ] }); 

const app = gun.get('park'); 
const dinos = app.get('dinos'); 

const velociraptor = app.get('velociraptor').put({ 
    statistics: { 
    force: 9, 
    speed: 15 
    } 
}); 

const trex = app.get('trex').put({ 
    statistics: { 
    force: 25, 
    speed: 5 
    } 
}); 

dinos.set(velociraptor); 
dinos.set(trex); 

//velociraptor.put(null); 
app.get('velociraptor').put(null); 

dinos.map().val((v, k) => { 
    console.log(k); 
    console.log(v); 
}); 

答えて

1

このnpmパッケージは、gunに対して 'unset()'メソッドを提供しています。

http://npmjs.com/package/gun-unset 
関連する問題