Template
single collection
multiple collections
mgodatagen
update
indexe
explain
Stage
Database
bson
mgodatagen
[{"comments":[1,2,3,4,5,6,7,8,9,0]},{"comments":[1,2,3,4,5,6,7,8,9,0]}]
Query
db.collection.aggregate([{$project:{comments:{$slice:["$comments",{$cond:[{$gte:[{$size:"$comments"},15]},-15,99999]},5]}}}])
Result