@@ -259,6 +259,10 @@ Select fields to aggregate, eg. aggregate the costs for selected stores:
259
259
>>> [a['account_id'] for a in response]
260
260
[u'sns_03821023', u'sns_09121024', u'bk_29151823', u'gm_49121229']
261
261
262
+ >>> response = transactions.find().limit(2)
263
+ >>> [a['account_id'] for a in response]
264
+ [u'sns_03821023', u'sns_09121024']
265
+
262
266
>>> response = transactions.find().skip(1).limit(3)
263
267
>>> [a['account_id'] for a in response]
264
268
[u'sns_09121024', u'bk_29151823', u'gm_49121229']
@@ -272,6 +276,31 @@ Select fields to aggregate, eg. aggregate the costs for selected stores:
272
276
[u'gm_49121229']
273
277
```
274
278
279
+ ## Indexes
280
+
281
+ Create index:
282
+
283
+ ```
284
+ >>> from pymongo import TEXT
285
+ >>> transactions.create_index([("store_name", TEXT)], name='store_index', default_language='english')
286
+ 'store_index'
287
+ ```
288
+
289
+ ## Delete Documents:
290
+
291
+ Delete selected documents:
292
+
293
+ ```
294
+ >>> transactions.remove({'account_id':'sns_03821029'})
295
+ {u'ok': 1.0, u'n': 2}
296
+ ```
297
+
298
+ Delete all documents:
299
+
300
+ ```
301
+ >>> transactions.remove()
302
+ ```
303
+
275
304
### Drop Collections
276
305
277
306
```
@@ -349,5 +378,7 @@ u'Cape Town'
349
378
350
379
## Resources
351
380
381
+ - https://itnext.io/indexing-and-mongodb-query-performance-a8a6a64c4308
352
382
- https://realpython.com/introduction-to-mongodb-and-python/
353
383
- https://docs.mongodb.com/charts/master/tutorial/movie-details/prereqs-and-import-data/
384
+ - https://www.tutorialspoint.com/mongodb/mongodb_relationships.htm
0 commit comments