showing results for - "how to query array of object in mongoos"
Bridie
07 Sep 2019
1User.findOne({'local.rooms': {$elemMatch: {name: req.body.username}}}, function (err, user) {
2
3        if (err){
4            return done(err);
5        }    
6
7        if (user) {
8            console.log("ROOM NAME FOUND");
9            req.roomNameAlreadyInUse = true;
10            next();
11
12        } else {
13            req.roomNameAlreadyInUse = false;
14            console.log("ROOM NAME NOT FOUND");
15            next();
16
17        }
18
19    });