From 9c585a0411f9adf4ec36b4a3bd1082bec0e6e679 Mon Sep 17 00:00:00 2001 From: Louis Chatriot Date: Thu, 23 May 2013 18:20:49 +0300 Subject: [PATCH] Update README.md --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 1130a82..b1be51f 100644 --- a/README.md +++ b/README.md @@ -103,10 +103,23 @@ db.find({ satellites: 'Phobos' }, function (err, docs) { // You can use comparison operators $lt (less than), $lte (less than or equal), // $gt (greater than) and $gte (greater than or equal) +// They work on numbers and strings (lexicographical order in that case) db.find({ "humans.genders": { $gt: 5 } }, function (err, docs) { // docs contains Omicron Persei 8, whose humans have more than 5 genders (7). }); +// You can use logical operator $or and $and ($and is the same +// as just using a normal query object) +// Syntax is { $logicalOperator: [query1, query2, ...] } +db.find({ $or: [{ planet: 'Earth' }, { planet: 'Mars' }] }, function (err, docs) { + // docs contains Earth and Mars +}); + +// You can mix normal queries, comparison queries and logical operators +db.find({ $or: [{ planet: 'Earth' }, { planet: 'Mars' }], inhabited: true }, function (err, docs) { + // docs contains Earth +}); + // Find all documents in the collection db.find({}, function (err, docs) { });