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

Allow Modifier Operations During Insert

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Major - P3
    • Resolution: Won't Fix
    • None
    • None
    • Write Ops
    • None

    Description

      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).

      Attachments

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved: