如何从集中删除节点?

时间:2017-11-02 16:31:21

标签: javascript node.js gun

如何从set中删除节点?

例如,我想从velociraptor集中删除dinos。但是当我运行脚本时,我仍然会在执行dinos之后看到dinos.map().val(cb)后面的两个节点。

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 个答案:

答案 0 :(得分:1)

可以尝试这个提供' unset()'的npm包。枪的方法。

http://npmjs.com/package/gun-unset