Javascript 如何从集合中删除节点?
如何从集合中删除节点 例如,我想从恐龙集合中删除velociraptor。但是当我运行脚本时,在执行dinos.map.valcb之后,我仍然可以看到dinos后面的两个节点Javascript 如何从集合中删除节点?,javascript,node.js,gun,Javascript,Node.js,Gun,如何从集合中删除节点 例如,我想从恐龙集合中删除velociraptor。但是当我运行脚本时,在执行dinos.map.valcb之后,我仍然可以看到dinos后面的两个节点 const Gun = require('gun'); const gun = new Gun({ peers: [ 'https://localhost:8888/gun' ] }); const app = gun.get('park'); const dinos = app.get('dinos'); c
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);
});
您可以尝试此npm软件包,该软件包为gun提供“unset”方法
http://npmjs.com/package/gun-unset