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

Ability to group several Mongoid atomic operation calls into one server operation

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None

      (Not at all urgent, just filing for future ideas. Please put in backlog.)

       

      Currently, the atomic operation API allows only one atomic action at a time:

      person = Person.all.first
      
      # the following lines perform 3 database actions
      person.set(name: "Bob")
      person.unset(:first_name)
      person.inc(likes: 1)
      

       

      It would be nice if we had a way to lazy evaluate the actions so the run as one command: 

      person = Person.all.first
      
      person.atomic.set(name: "Bob").unset(:first_name).inc(likes: 1).perform
      

      In the above #atomic is analogous to Enumerable.lazy method.

      (Often I find that I do pull and push, set and unset, etc. together in the same places in my code, so this could have some performance advantage.)

            Assignee:
            Unassigned Unassigned
            Reporter:
            shields@tablecheck.com Johnny Shields
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: