Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-2642

Allow Modifier Operations During Insert

    • Type: Icon: Improvement Improvement
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Write Ops
    • Labels:

      A large convenience to developers, would be the ability to use modifier operations during an insert. I propose the addition of a second argument for "insert", the purpose of which would be to accept a hash of modifier operations . E.g. db.test.insert({}, {$set :

      {name: 'bob'}

      , $inc: {age: 3}})

      The purpose of the previous example would be to insert a new document (with an auto-generated ID), and then apply the given modifiers (or what one may call the "update" clause) to that new document. Basically, there needs to be some way to apply modifier operations during an insert, as this is a relatively common requirement for object mappers and the like. In an object mapper I'm writing at the moment, the only work-around I've found is to issue a blank insert (for the sole purpose of inserting a new document and generating an ID), followed by an update (or a findAndModify in my specific circumstance).

            Unassigned Unassigned
            wardrop Tom Wardrop
            0 Vote for this issue
            2 Start watching this issue