根据当前值更新MongoDB中的值 [英] Update a value in MongoDB based on its current value
本文介绍了根据当前值更新MongoDB中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想做这样的事情,但是this
关键字似乎没有在更新语句中设置.
I want to do something like this, but the this
keyword doesn't seem to be set inside the update statement.
db.items.update({foo:…}, {$set: {bar: this.foo}}, false, true)
我必须使用eval
来完成此操作吗?
Do I have to use eval
to accomplish this?
推荐答案
是的,您不能在修饰符中引用其他字段.您必须使用db.eval.
Yes, you can't refer to other fields in the modifier. You'll have to use db.eval.
这篇关于根据当前值更新MongoDB中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文