const query_id = [1,2,3,4,5,6];
const query_type = "A";
const queries = await Query.find({
_id: query_id
}).find({
query_type: query_type
});
The code above does work. However, it doesn't seem to be the correct way in terms of good practice and elegances.
What is that way?
CodePudding user response:
.find( { _id: { $in: query_id } } )
Edit:
.find({ $and: [{query_type: query_type},{ _id: { $in: query_id }] } )
see all queries https://docs.mongodb.com/manual/reference/operator/query/and/#mongodb-query-op.-and