简体   繁体   中英

Can't get data by using aggregate in mongodb

Server mongo version is 3.4.4. Connected by Studio 3T. When I query like this in IntelliShell

db.orders.aggregate([
    { $limit: 10 },
    { $skip: 10 }
])

I get nothing returned.
However, when I switch the $limit and $skip,

db.orders.aggregate([
    { $skip: 10 },
    { $limit: 10 }
])

It works fine.

This is my understanding: The $limit: 10 means 'I want ten result', and the $skip means 'I don't need the first tens'.
So, I get 0 results by the first query, get 10-20 results by the second query.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM