使用 mongo-ruby-driver 进行文档更新?
假设如下:
irb> x
irb> => {"_id"=> 123456, "welcome"=>"Hi!", "welcome2" => "Enjoy your stay!"}
irb> coll.class
irb> => Mongo::Collection
如何使用原始的 mongo-ruby-driver 通过重写方法和原子更新方法来更新 x 对应的文档? (参见http://api.mongodb.org/ruby/current/file .TUTORIAL.html#Updating_a_Document)
Assuming the following:
irb> x
irb> => {"_id"=> 123456, "welcome"=>"Hi!", "welcome2" => "Enjoy your stay!"}
irb> coll.class
irb> => Mongo::Collection
How can I use the raw mongo-ruby-driver to update the document corresponding to x by using both the rewriting method and the atomic update method? (See http://api.mongodb.org/ruby/current/file.TUTORIAL.html#Updating_a_Document)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
给定您的示例输出,如果您想使用重写方法,它将像这样:
或者如果您想原子地更改一个值,它将像这样:
given your example output, if you want to use the rewriting method it would be like this:
or if you want to atomically change a value, it would be like this: