Given a model User with the field username is there a way to select all users with a username in an array? I could use a for loop like so to iterate through all the usernames:
var usernamesToFind = ["username", "anotherUsername", "etc"];
for (i = 0; i < usernameToFind.length; i++) {
User.find({ "username": usernamesToFind[i] }, function(err, foundUser) {
//notify user they got tagged
});
}
Is it possible to achieve the result of above loop with one query, where instead of getting username by username, I do one query and get a list of users whose username matched any of the given usernames?