I wanted to query a user through a cookie like so
User.findById(req.signedCookies.userid,
and then query an array within the user for another user id.
The array is friendRequest and I am querying for another user's id. I then want to return true or false depending whether or not the user's id exists.
This is for mongoDB. (I am using mongoose with node.js)
The query to check if a user exists would be
User.find({_id: req.signedCookies.userid, friendRequest: friendRequesId})
this will only return a result if the user match and it contains a matching friendRequest
example
> db.t.insert({id: 1, users:[2,3,4]})
> db.t.findOne({id:1, users: 2})