연산자 (Operator)

Insert Operators

$lt and $lte

db.collection.find({'field' : {'$lt': 2}})
db.collection.find({'field' : {'$lte': 1}}) 

$gt and $gte

db.collection.find({'field' : {'$gt': 1}})
db.collection.find({'field' : {'$gte': 2}}) 

$ne

db.collection.find({'field' : {'$ne' : 'value'}}) 

$in and $nin

db.collection.find({'field' : {'$in' : ['element_1', 'element_2']}})
db.collection.find({'field' : {'$nin' : ['element_1', 'element_2']}})

$or

db.collection.find({"$or":[{'field_1' :'value'}, {'field_2' : 'value'}]}) 

$all

$elemMatch

Query an Embedded Document or Array of Embedded Document

$slice

Update Operators

  • Two ways to manipulate values in arrays.

    • By position

    • Position operator (the $ character)

      • When we don’t know what index of the array to modify.

      • Updates only the first match.

    • Example

Last updated

Was this helpful?