I am trying to find the documents in the my collection using find() command in MongoDB,
can anybody explain why it doesn’t work? and correct command to execute the same ?
j = {name:"mongo",property:{type:"database",lang:"cpp"}};
{
"name" : "mongo",
"property" : {
"type" : "database",
"lang" : "cpp"
}
}
db.dummy.save(j);
db.dummy.find({"property" : { "type" : "database" }});
The last command deosn’t return anything to me. I am not able to understand why. What do I do if I
In mongodb there is concept of dot notation. So to reach into embedded documents you should use dot notation. In your case it will looks like:
Or you can search by full object match like this: