mongodb - What is the difference between $push/$sort and .sort() at query time? -
so, retrieval purposes, difference between two? think $push/$sort feature new in 2.4 yet still don't understand how different using .sort() on sub-document array while querying parent. using $push/$sort better approach? save use of index on subdoc array?
2.4 introduced feature allows keep "last/best/top/first" n elements of array when $push
new values during update. way specifying field , direction use $sort
, $slice
tell how many keep.
when query , use sort()
applies documents being returned, not elements of arrays inside of such documents.
see more description of capped array feature here.
Comments
Post a Comment