Details
-
Task
-
Resolution: Done
-
Major - P3
-
mongodb-2.4
-
None
Description
In MongoDB 2.4 (tested with 2.4.6) you cannot push to a sorted array without also specifying a $slice.
eg. modifying the example from http://docs.mongodb.org/manual/reference/operator/push/:
db.students.update( { name: "joe" },
|
{ $push: { quizzes: { $each: [ { id: 3, score: 8 },
|
{ id: 4, score: 7 },
|
{ id: 5, score: 6 } ],
|
$sort: { score: 1 }
|
}
|
}
|
}
|
)
|
Returns the error:
cannot have a $sort without a $slice
|
I think this caveat should be mentioned on :