开发者

How can I update increment two fields in one command in MongoDB?

开发者 https://www.devze.com 2023-03-29 22:50 出处:网络
The documentation tells me this is legal if I want to set one value and 开发者_如何学Cincrement another:

The documentation tells me this is legal if I want to set one value and 开发者_如何学Cincrement another:

{ $set : { x : 1 }, $inc : { y : 1 } }

What if I want increment both variables? I'm trying this but it isn't working:

{ $inc : [{ y : 1 }, { x : 1 }] }

Is this possible?


I'm an idiot:

{ $inc : { y : 1, x : 1 } }

0

精彩评论

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