2

MongoDB findAndModify 可以获取当前要修改的值吗?

 1 year ago
source link: https://www.v2ex.com/t/901503
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  问与答

MongoDB findAndModify 可以获取当前要修改的值吗?

  franklinre · 7 小时 17 分钟前 · 204 次点击

大家好!请教一个问题。 现在有个需求是:要从 MongoDB 获取指定对象,然后在代码层面根据获取的对象值做一些计算,并同时把用户信息一起放进去,且要用 findAndModify 保证原子性。 现在我遇到的问题是:不知如何获取的对象值。 这些操作可以通过 findAndModify 同时完成吗? 翻了文档,没找到相应的方法,也不能传函数进去。 如果搞不了,那只能先放用户信息进去,再查一下,再进行修改了。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK