本文介绍了如何在Mongoose中执行ID数组查询?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个名为User的模型.我有一个包含对象ID的数组.

Let's say I have a model called User.I have an array with object Ids.

我想获得与我拥有的ID数组相交"的所有用户记录.

I want to get all User records that "intersect" with the array of Ids that I have.

User.find({ records with IDS IN [3225, 623423, 6645345] }, function....

推荐答案

您需要使用$ in运算符>

You need to use the $in operator >

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

例如:

Users.find( { "fb" : { id: { $in : arrayOfIds } } }, callback );

这篇关于如何在Mongoose中执行ID数组查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 06:07
查看更多