> For the complete documentation index, see [llms.txt](https://koonkim.gitbook.io/mongodb/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://koonkim.gitbook.io/mongodb/crud/operator.md).

# 연산자 (Operator)

## Insert Operators

### $lt and $lte

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

### $gt and $gte

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

### $ne

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

### $in and $nin

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

### $or

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

### $all

```python
db.collection.find({ <field>: { $all: [ <value1>, <value2>, ... ] } })
```

### $elemMatch

```python
db.collection.find({"<array_field>":{"$elemMatch":{"<field>": "<value>"}}}) 
```

### Query an Embedded Document or Array of Embedded Document

```python
db.collection.find({"<array_field>.<field>": "<value>"})
```

### $slice

```python
db.collection.find({}, {"field":{"$slice": <limit>}})
db.collection.find({}, {"field":{"$slice":[<skip>, <limit>]}})
```

## 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

```python
collection.update_one({<query>}, {"$inc" : {“comments.0.like” : 1}})
collection.update_many({<query>}, {"$inc" : {“comments.$.like” : 1}})
```

##
