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

$push with $slice + $sort

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 2.3.2
    • Affects Version/s: None
    • Component/s: Write Ops
    • None

      You can now limit the resulting elements in the array after you push. The new syntax is :

      db.coll.update({...}, {$push: { $each:[<values>], $slice:-N, $sort:{...}}}
      

      The initial implementation (see SERVER-8069 for more) only supports negative slice (taking stuff from the end of the array).

      Sorting is by embedded document fields and doesn't work any type which is not an embedded docs (in the array).

            Created:
            Updated:
            Resolved: