我一直在开发一些东西,你知道在早期原型(prototype)制作期间,类型和表格变化很快......清理旧数据并在某些网格中重新开始会很好。
现在我使用的是示例 HTTP 服务器,所以我删除了 data.json;但是我忘了浏览器中的localStorage也需要清除。
有人可能会认为你可以把(null)
我在 gitter 上问了一下,得到了
https://github.com/amark/gun/wiki/delete
except for deletes , lol, our excuse is "It works like your OS, when you delete >something it just gets tossed in the trash/recycle bin. That's all." better safe than sorry though
if you are trying to "delete" stuff because you messed up while developing >something, follow this three step process: 1) localStorage.clear() in every >browser tab you have up, 2) Crash the server and rm data.json, 3) restart >everything. You should then have a clean slate. Often times while I'm >devleoping something I put localStorage.clear() at the top of my code so I only >have to worry about clearing the server.
最佳答案
欢迎来到枪支社区!感谢您提出问题。
是的,删除数据最简单的方法是使用gun.put(null)
。采取:
var gun = Gun();
var users = gun.get('users');
users.put({alice: {name: 'alice'}, bob: {name: 'bob'}});
// now let's delete bob
users.path('bob').put(null);
但是,如果(正如您在问题中提到的那样),您的意思是“删除数据”,就像在开发您的应用程序时想要清除错误一样。您需要执行您提到的操作:localStorage.clear()
在所有浏览器中,使所有服务器和 rm data.json
崩溃。
对于其他开发人员,了解 gun 使用一种墓碑方法可能会很有用。您实际上不能删除节点本身,它们只会被取消引用,有点像您的操作系统只是将文件移动到垃圾箱/回收站中。这种墓碑方法在分布式环境中非常重要,这样“删除”操作就会复制到每个对等点。
感谢您回答自己的问题!一如既往,如果您迷路或需要帮助,请调用 https://gitter.im/amark/gun .
关于database - 如何删除枪支数据库中的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37758618/