mongoDB 入门
- GUI:https://docs.mongodb.org/ecosystem/tools/administration-interfaces/#third-party-open-source-tools
- Python文档:https://docs.mongodb.org/getting-started/python/
- 查询:https://docs.mongodb.org/getting-started/python/query/
- 点操作符:https://docs.mongodb.org/manual/core/document/#document-dot-notation
- Pymongo模块API:https://api.mongodb.org/python/current/api/pymongo/collection.html
快速参考文档ReferenceCards-PDF
from pymongo import MongoClient
client = MongoClient()
db = client.test
# queries for all documents in the restaurants collection
cursor = db.restaurants.find()
条件查询 Specify Equality Conditions
{ <field1>: <value1>, <field2>: <value2>, ... }
https://docs.mongodb.org/manual/core/document/#document-dot-notation
Query by a Top Level Field
cursor = db.restaurants.find({"borough": "Manhattan"})
Query by a Field in an Embedded Document
cursor = db.restaurants.find({"address.zipcode": "10075"})
Query by a Field in an Array
following queries for documents whose grades array contains an embedded document with a field grade equal to "B".
cursor = db.restaurants.find({"grades.grade": "B"})
条件查询 Specify Conditions with Operators
{ <field1>: { <operator1>: <value1> } }