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

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -