Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5f28f0d

Browse files
find documents
1 parent b3de902 commit 5f28f0d

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

‎README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,26 @@ We can batch up our writes:
101101
>>> response.inserted_ids
102102
[ObjectId('5cad18d4a5f3826f6f046d75'), ObjectId('5cad18d4a5f3826f6f046d76'), ObjectId('5cad18d4a5f3826f6f046d77')]
103103
```
104+
105+
### Find One Document:
106+
107+
```
108+
>>> transactions.find_one({'account_id': 'gm_49121229'})
109+
{u'account_id': u'gm_49121229', u'store_name': u'game', u'purchase_method': u'cash', u'branch_name': u'bellvile', u'products_purchased': [u'ps4 remote'], u'_id': ObjectId('5cad18d4a5f3826f6f046d77'), u'total_costs': 499.99}
110+
```
111+
112+
### Find Many Documents:
113+
114+
```
115+
>>> response = transactions.find({'purchase_method': 'cash'})
116+
>>> [doc for doc in response]
117+
[{u'account_id': u'bk_29151823', u'store_name': u'burger king', u'purchase_method': u'cash', u'branch_name': u'somerset west', u'products_purchased': [u'cheese burger', u'pepsi'], u'_id': ObjectId('5cad18d4a5f3826f6f046d76'), u'total_costs': 89.99}, {u'account_id': u'gm_49121229', u'store_name': u'game', u'purchase_method': u'cash', u'branch_name': u'bellvile', u'products_purchased': [u'ps4 remote'], u'_id': ObjectId('5cad18d4a5f3826f6f046d77'), u'total_costs': 499.99}]
118+
```
119+
120+
Or filtering down the results to only the account id:
121+
122+
```
123+
>>> response = transactions.find({'purchase_method': 'cash'})
124+
>>> [doc['account_id'] for doc in response]
125+
[u'bk_29151823', u'gm_49121229']
126+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /