Mongo中的光标是否指向相同的结果?

发布于 2025-02-09 13:35:18 字数 389 浏览 0 评论 0原文

如果我要使用光标参考一些结果,是否有区别,是否要检索文档和文档的总数? (我还使用跳过和限制参数)

在这种情况下,光标是否返回相同数量的文档,用于TotalCount和Docs:

const builtQuery = { ... };

const myCursor = MyCollection.collection.find(builtQuery);
const totalCount = await myCursor.count();
const docs = await myCursor.skip().limit().toArray();

是否在相同的请求中完成了总计和文档?我怎么知道它将返回文档的确切总计?如果请求文档需要更多的时间,而总计数字较小或更大,则Docs编号。

Is there a difference if I use cursor to refer to some results or not if I want to retrieve documents and total count of documents? (I am also using skip and limit params)

Is cursor returning the same number of docs in this case for totalCount and docs:

const builtQuery = { ... };

const myCursor = MyCollection.collection.find(builtQuery);
const totalCount = await myCursor.count();
const docs = await myCursor.skip().limit().toArray();

Is totalCount and docs done in the same request? How can I know that it will return the exact totalCount of the docs? What if requesting docs takes more time and the totalCount number is smaller or bigger that docs number.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文