@@ -166,6 +166,27 @@ gte - Greater Than Equals
166
166
ne - Not Equals
167
167
```
168
168
169
+ ## Range Queries:
170
+
171
+ ```
172
+ >>> import datetime
173
+ >>> new_posts = [{"author": "Mike","text": "Another post!","tags": ["bulk", "insert"],"date": datetime.datetime(2009, 11, 12, 11, 14)},{"author": "Eliot","title": "MongoDB is fun","text": "and pretty easy too!","date": datetime.datetime(2009, 11, 10, 10, 45)}]
174
+ >>> db.posts.insert(new_posts)
175
+ [ObjectId('5cb439c0f90e2e002a164d15'), ObjectId('5cb439c0f90e2e002a164d16')]
176
+
177
+ >>> for post in db.posts.find():
178
+ ... post
179
+ ...
180
+ {u'date': datetime.datetime(2009, 11, 12, 11, 14), u'text': u'Another post!', u'_id': ObjectId('5cb439c0f90e2e002a164d15'), u'author': u'Mike', u'tags': [u'bulk', u'insert']}
181
+ {u'date': datetime.datetime(2009, 11, 10, 10, 45), u'text': u'and pretty easy too!', u'_id': ObjectId('5cb439c0f90e2e002a164d16'), u'author': u'Eliot', u'title': u'MongoDB is fun'}
182
+
183
+ >>> d = datetime.datetime(2009, 11, 11, 12)
184
+ >>> for post in db.posts.find({"date": {"$lt": d}}).sort("author"):
185
+ ... post
186
+ ...
187
+ {u'date': datetime.datetime(2009, 11, 10, 10, 45), u'text': u'and pretty easy too!', u'_id': ObjectId('5cb439c0f90e2e002a164d16'), u'author': u'Eliot', u'title': u'MongoDB is fun'}
188
+ ```
189
+
169
190
## Updates
170
191
171
192
Let's say we want to change a transactions payment method from credit card to account:
0 commit comments