Quantcast
Channel: Other – Michał Szałkowski – Blog
Viewing all articles
Browse latest Browse all 125

MongoDB – Part 2

$
0
0

Comparison Query Operators

The $in operator selects the documents where the value of a field equals any value in the specified array.

$in:

db.cats.find({color:{$in:['white','black']}});

not in: $nin:

db.cats.find({color:{$nin:['white','black']}});

Update multi items useing $in

db.cats.update({color:{$in:['black','white']}},{$set:{group:1}},{multi:true});

mongo19

Other Comparison Query Operators

  • $gt – Matches values that are greater than the value specified in the query.
  • $gte – Matches values that are greater than or equal to the value specified in the query.
  • $lt – Matches values that are less than the value specified in the query.
  • $lte – Matches values that are less than or equal to the value specified in the query.
  • $ne – Matches all values that are not equal to the value specified in the query.
db.cats.find({age:{$gt:4}});
db.cats.find({age:{$gte:4}});
db.cats.find({age:{$lt:4}});
db.cats.find({age:{$lte:4}});
db.cats.find({age:{$ne:4}});


Viewing all articles
Browse latest Browse all 125

Trending Articles