-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:
This is a ridiculous feature request and you can do it by dropping to the Mongo driver but it would be downright sick if mongoid supported translating chained atomic commands to form a bigger atomic command.
For example:
@post= Post.find(params[:post_id])
@post.add_to_set(:likers, @current_user.id)
@post.inc(:likes, 1)
Here, all of the commands are individually atomic but not atomic together.
My idea is that this could become:
@post= Post.find(params[:post_id]).add_to_set(:likers, @current_user.id).inc(:likes, 1)
It would be executed in one atomic update.
Tears would be shed if this was possible in ORM language.