Add a 'initial value' parameter to $inc

XMLWordPrintableJSON

    • Type: New Feature
    • Resolution: Won't Do
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Write Ops
    • None
    • Query
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      $inc is great to increment an existing field by a given amount, however for a newly created document you should be able to set the initial value for the field, rather than to assume it should be the same as the increment value.

      Change

      { $inc: { <field1>: <amount1>, <field2>: <amount2>, ... } } 
      

      To

      { $inc: { <field1>: {start:<value1>, next:<amount1},
                   <field2>:  {start:<value2>, next:<amount2}, ... } } 
      

      This need became apparent when using upsert = true on an update with a field that is normally incremented if it exists, but should have a user defined starting value when it does not.

              Assignee:
              Backlog - Query Team (Inactive)
              Reporter:
              Edem Nsefik
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: