MongoDB Comparison Query Operators

I have been working through the M001: MongoDB Basics course on MongoDB University. Here are some notes on Comparison Query Operators and my MongoDB Shell and Compass examples.

Descriptions from MongoDB documentation.

Name Description
$eq Matches values that are equal to a specified value.
$gt Matches values that are greater than a specified value.
$gte Matches values that are greater than or equal to 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 specified in an array.
$nin Matches none of the values specified in an array.

Shell Examples

 

Compass Examples

$eq

$gt

$gte

$lt

$lte

$ne

$in

$nin

Leave a Reply

Your email address will not be published. Required fields are marked *