简体   繁体   English

在mongodb中使用聚合无法获取数据

[英]Can't get data by using aggregate in mongodb

Server mongo version is 3.4.4. 服务器mongo版本是3.4.4。 Connected by Studio 3T. 通过Studio 3T连接。 When I query like this in IntelliShell 当我在IntelliShell中这样查询时

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

I get nothing returned. 我什么也得不到。
However, when I switch the $limit and $skip, 但是,当我切换$ limit和$ 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'. 这是我的理解: $limit: 10表示“我想要十个结果”, $skip表示“我不需要前十个”。
So, I get 0 results by the first query, get 10-20 results by the second query. 因此,我通过第一个查询获得0个结果,通过第二个查询获得10-20个结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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