Mongodb querying for multiple parameters

Posted by gaggina on Stack Overflow See other posts from Stack Overflow or by gaggina
Published on 2012-08-31T15:37:16Z Indexed on 2012/08/31 15:38 UTC
Read the original article Hit count: 254

Filed under:
|

I've this collections

{
    "name" : "montalto",
    "users" : [
        {
            "username" : "ciccio",
            "email" : "aaaaaaaa",
            "password" : "aaaaaaaa",
            "money" : 0
        }
    ],
    "numers" : "8",
    "_id" : ObjectId("5040d3fded299bf03a000002")
}

If I want to search for a collection with the name of montalto and a user named ciccio I'm using the following query:

db.coll.find({name:'montalto', users:{username:'ciccio'}}).count()

But it does not work. Where I went wrong?

© Stack Overflow or respective owner

Related posts about node.js

Related posts about mongodb