Skip to main content

Mongodb Query

·122 words·1 min
Mongodb
Rory
Author
Rory
Step by step the ladder is ascended

Record some Mongodb query example.

Match by a Single Condition
#

{ name: "Andrea Le" }

Match by Multiple Conditions ($and)
#

{ scores: 75, name: "Greg Powell" }

{$and: [{ status: { $ne: 'available' }},{ status: { $ne: 'XR' }}]}

Match by Multiple Possible Conditions ($or)
#

{ $or: [ { version: 4 }, { name: "Andrea Le" } ] }

Match by Exclusion ($not)
#

{ name: { $not: { $eq: "Andrea Le" } } }

Match with Comparison Operators
#

{ version: { $lte: 4 } }

Match by Date
#

{ dateCreated: { $gt: new Date('2000-06-22') } }

Match by Array Conditions
#

{ scores: { $elemMatch: { $gt: 80, $lt: 90 } } }

Query Your Data