2
Mongo具有很好的操作符$ slice,這讓您只需檢索entiry的嵌入式數組的子集。從他們的官方文檔:mongo slice,默認排序是什麼,可以更改
db.posts.find({}, {comments:{$slice: 5}}) // first 5 comments
db.posts.find({}, {comments:{$slice: -5}}) // last 5 comments
db.posts.find({}, {comments:{$slice: [20, 10]}}) // skip 20, limit 10
db.posts.find({}, {comments:{$slice: [-20, 10]}}) // 20 from end, limit 10
但是我無法找到它最高審計機關如何被獲取這種方式之前,嵌入式陣列的元素是有序的。而且,更重要的是,我可以在$切片之前更改順序嗎?
明白了,插入順序,就是這樣。謝謝 – 2012-02-08 09:25:02
@AndreiBodnarescu:剛試過寫了一個很好的解釋。 – 2012-02-08 09:30:24