您应该看一下$in
MongoDB 中的运算符。然后将它与find一起使用,以使您的请求更快,可以使用lean
方法:使用它,mongoDB将返回JS对象而不是Mongoose模型/对象。
YourModel.find({storeID: {$in: storeIDarray }}).lean().exec(yourCallback);
然后,您可以reduce
在结果数组上使用方法:
yourResult.reduce((acc, el) => acc.concat(el.sensorID), []);
希望对您有帮助, 最好的问候