在 MongoDB 集合中进行更新时,有什么方法可以访问文档的原始值?我一直在做以下事情:
db.things.find().forEach(function (t) {
t.name = t.name + ' new'; // Appends ' new' to the end of the original value
db.things.save(t);
});
上面的性能相当慢(不过,我正在处理 220 万个文档),所以我希望传统的 update() 性能更好。我检查了文档,但我没有注意到任何提到将原始值的一部分应用于 $set 值的内容。