【发布时间】:2011-05-28 01:55:30
【问题描述】:
我正在使用 Mongoose 库通过 node.js 访问 MongoDB
有没有办法从文档中删除密钥?即不只是将值设置为 null,而是将其删除?
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();
});
【问题讨论】:
-
我以为我找到了它,但经过一些测试:可能没有。不过,这对这个话题有一些很好的讨论。 groups.google.com/group/mongoose-orm/browse_thread/thread/…
-
哈哈没关系,我猜这是你的帖子!
标签: mongodb node.js mongoose document-database