Answers for "how to query array of object in mongoos"

-1

how to query array of object in mongoos

User.findOne({'local.rooms': {$elemMatch: {name: req.body.username}}}, function (err, user) {

        if (err){
            return done(err);
        }    

        if (user) {
            console.log("ROOM NAME FOUND");
            req.roomNameAlreadyInUse = true;
            next();

        } else {
            req.roomNameAlreadyInUse = false;
            console.log("ROOM NAME NOT FOUND");
            next();

        }

    });
Posted by: Guest on August-23-2020

Code answers related to "how to query array of object in mongoos"

Code answers related to "Javascript"

Browse Popular Code Answers by Language