Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

monngoose find from an array using in

//If teamIds is already an array, then you shouldn't wrap it in another array:

Team.find({
    '_id': { $in: teamIds }
}, function(err, teamData) {
    console.log("teams name  " + teamData);
});

//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);
});

Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #monngoose #find #array
ADD COMMENT
Topic
Name
8+6 =