开发者

Update a value in MongoDB based on its current value

开发者 https://www.devze.com 2022-12-23 06:24 出处:网络
I want to do something like开发者_StackOverflow社区 this, but the this keyword doesn\'t seem to be set inside the update statement.

I want to do something like开发者_StackOverflow社区 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)

Do I have to use eval to accomplish this?


Yes, you can't refer to other fields in the modifier. You'll have to use db.eval.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号