访问MongoDB的一个MongoDB的文档的关键是有没有办法删除文档的关键?即不是仅将该值设置为空,而是将其删除?
User.findOne({}, function(err, user){
//correctly sets the key to null... but it's still present in the document
user.key_to_delete = null;
// doesn't seem to have any effect
delete user.key_to_delete;
user.save();
});
我想我已经找到了,但一些测试后:可能不会。尽管如此,这个主题还是有一些很好的讨论。 http://groups.google.com/group/mongoose-orm/browse_thread/thread/6053e3b8d4fe9098 – Stephen 2011-08-15 15:28:52
大声笑没关系,我想这是你的帖子! – Stephen 2011-08-15 15:31:33
其实它是我的:) – staackuser2 2011-08-22 22:26:03