Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1345

Atomic Command Rework: Chaining, Multi-Update, Dot Notation.

    • Type: Icon: Task Task
    • Resolution: Done
    • 4.0.0 final
    • 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.

            Assignee:
            durran Durran Jordan
            Reporter:
            TylerBrock TylerBrock [X]
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: