Is there a way to search for a value in mongodb in object with arrays, and the value could be present in any object of that array

This is the structure:


and i have many documents as this, I want to search in participants blue/red for a specific name and to return that document. For code I`m using javascript, I tried something like this:

await gamesSchema.find().where('').in(player[0].Nickname);

but this only return, I could make another call for blue but I would like them in the order as they are in database, so I`m asking if there is a method to search at once.


Try an $or condition :

await gamesSchema
        $or : [{
            "" : player[0].Nickname
            "" : player[0].Nickname
    .lean() // Returns simple JSON, not a collection of Mongoose objects
    .exec(); // Returns a true Promise, not a thenable. Good with await