Comparison Operators

These operators allow to match based on a fields value relative to some other value.

๐Ÿ“Œ $gt, $lt

db.movieDetails.find({โ€œruntimeโ€: {$gt: 90, $lt: 120}})

You can also add more than one filter.

db.movieDetails.find({โ€œruntimeโ€: {$gt: 90, $lt: 120}, โ€œtomato.meterโ€: {$gte: 95}})

๐Ÿ“Œ $ne

Values that are not equal to some specific value.

db.movieDetails.find({โ€œratedโ€: {$ne: โ€œUNRATEDโ€}})

๐Ÿ“Œ $in

Allows to specify one or more values. This filter will look to match any value that is defined in the array value.

db.movieDetails.find({โ€œratedโ€: {$in: [โ€œGโ€, โ€œPGโ€]}})

$nin does the opposite operation to $in

Last updated