Blog

MongoDB Query Selector Comparison Operators
Posted on July 17, 2015 in MongoDB by Matt Jennings

Explanation of MongoDB Query Operators

Quote from http://docs.mongodb.org/manual/reference/operator/ on July 17, 2015:

Query operators provide ways to locate data within the database and projection operators modify how data is presented.

Use the $gt Operator to Find Documents in the schools Collection with Students Great than 15

db.schools.find( { num_students: {$gt: 15} } ).pretty()

Other Comparison Operators

  • $eq
    Matches values that are equal to a specified value.
  • $gte
    Matches values that are greater than a specified value.
  • $lt
    Matches values that are less than a specified value.
  • $lte
    Matches values that are less than or equal to a specified value.
  • $ne
    Matches all values that are not equal to a specified value.
  • $in
    Matches any of the values in a specified array.
  • $nin
    Matches none of the values specified in an array.

Leave a Reply

To Top ↑