@@ -101,3 +101,26 @@ We can batch up our writes:
101
101
>>> response.inserted_ids
102
102
[ObjectId('5cad18d4a5f3826f6f046d75'), ObjectId('5cad18d4a5f3826f6f046d76'), ObjectId('5cad18d4a5f3826f6f046d77')]
103
103
```
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