Answers for "mongoose find id in array"

Go
1

mongodb findmany

model.find({
    '_id': { $in: [
        mongoose.Types.ObjectId('4ed3ede8844f0f351100000c'),
        mongoose.Types.ObjectId('4ed3f117a844e0471100000d'), 
        mongoose.Types.ObjectId('4ed3f18132f50c491100000e')
    ]}
}, function(err, docs){
     console.log(docs);
});
Posted by: Guest on December-27-2019
0

find by array of ids mongoose

User.find({ _id: { $in: followedIDs } }, (err, verbs) => {});
Posted by: Guest on April-07-2021
0

find items from array of ids mongoose

const records = await Model.find().where('_id').in(ids).exec();
Posted by: Guest on June-29-2021
0

mongoose find in array

Or, if teamIds is a string of comma-separated id values, you need to convert it into an array of values using split:
Team.find({
    '_id': { $in: teamIds.split(',') }
}, function(err, teamData) {
    console.log("teams name  " + teamData);
});
Posted by: Guest on November-03-2021

Browse Popular Code Answers by Language