From fbb61d42dbc2fc388d1867b573ca07f429004b00 Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Wed, 22 May 2013 16:36:53 +0200 Subject: [PATCH] Update README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3a2f30b..7b325c6 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ You can use `find` to look for multiple documents matching you query, or `findOn ```javascript // Let's say our datastore contains the following collection // { _id: 'id1', planet: 'Mars', system: 'solar', inhabited: false } -// { _id: 'id2', planet: 'Earth', system: 'solar', inhabited: true, humans: { genders: 2 } } +// { _id: 'id2', planet: 'Earth', system: 'solar', inhabited: true, humans: { genders: 2, eyes: true } } // { _id: 'id3', planet: 'Jupiter', system: 'solar', inhabited: false } // { _id: 'id4', planet: 'Omicron Persia 8', system: 'futurama', inhabited: true } @@ -84,6 +84,11 @@ db.find({ "humans.genders": 2 }, function (err, docs) { // docs contains Earth }); +// You can also deep-compare objects. Don't confuse this with dot-notation! +db.find({ humans: { genders: 2 } }, function (err, docs) { + // docs is empty, because { genders: 2 } is not equal to { genders: 2, eyes: true } +}); + db.find({}, function (err, docs) { // docs contains all documents in the collection });