Skip to content

Commit 4d3da6c

Browse files
authored
Update README.md
1 parent 5fefbb7 commit 4d3da6c

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ Select fields to aggregate, eg. aggregate the costs for selected stores:
259259
>>> [a['account_id'] for a in response]
260260
[u'sns_03821023', u'sns_09121024', u'bk_29151823', u'gm_49121229']
261261
262+
>>> response = transactions.find().limit(2)
263+
>>> [a['account_id'] for a in response]
264+
[u'sns_03821023', u'sns_09121024']
265+
262266
>>> response = transactions.find().skip(1).limit(3)
263267
>>> [a['account_id'] for a in response]
264268
[u'sns_09121024', u'bk_29151823', u'gm_49121229']
@@ -272,6 +276,31 @@ Select fields to aggregate, eg. aggregate the costs for selected stores:
272276
[u'gm_49121229']
273277
```
274278

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+
275304
### Drop Collections
276305

277306
```
@@ -349,5 +378,7 @@ u'Cape Town'
349378

350379
## Resources
351380

381+
- https://itnext.io/indexing-and-mongodb-query-performance-a8a6a64c4308
352382
- https://realpython.com/introduction-to-mongodb-and-python/
353383
- 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

Comments
 (0)