I've got this array of usernames ['user1','user2'] and I want to query information about these users.
I thought
User.find({userName : users}, function(err, results) {
callback(results);
});
would work, but it only works when there is 1 user in the array.(ex. ['user1'])
Is it even possible to do something like that, or should I do a query for every user ?
You want to do an IN query so it matches what's inside the array. haven't test this, but something similar to this is what you're looking for:
User.find({userName : {$in: users}}, function(err, results) {
callback(results);
});