-
Type: Task
-
Resolution: Gone away
-
Priority: Minor - P4
-
Affects Version/s: None
-
Labels:
The $slice(projection) operator can be used with an array as 1st parameter, like the $slice(aggregation) operator.
db.posts.find( {}, { com: { $slice: ["$comments", 1, 3] } } )
This is told by the server error when we use only 1 parameter in an array
db.posts.find( {}, { comments: { $slice: [3] } } )
Invalid $slice syntax. The given syntax { $slice: [ 3 ] } did not match the find() syntax because :: Location31272: $slice array argument should be of form [skip, limit] :: The given syntax did not match the expression $slice syntax. :: caused by :: Expression $slice takes at least 2 arguments, and at most 3, but 1 were passed in.
The review must be done by the server team, I've only found this undocumented supported feature.