我可以通过id从Mongo检索多个文档吗? [英] Can I retrieve multiple docs from Mongo by id?

查看:90
本文介绍了我可以通过id从Mongo检索多个文档吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组id,我想立刻检索所有这些ID。这有可能吗,我可以以某种方式传递一系列ID并让它们全部归还给我吗?如果是这样,怎么样?

I have an array of ids and I want to retrieve all of them at once. Is this possible, can I pass an array of ids somehow and have all of them returned to me? If so, how?

我正在使用节点本机驱动程序。

I'm using the node-native driver.

谢谢!

推荐答案

你需要使用 $ in 运算符,这将为您提供所需的结果。

you need to use $in operator, that would give you desired result.

https://docs.mongodb.com/manual/reference/operator/query/in/

这篇关于我可以通过id从Mongo检索多个文档吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆