質問

what is the PyMongo way for db.collection.find(criteria, projection).I cant find any doc for specifying projection to the collection.find() method

役に立ちましたか?

解決

Is equeal to mongo shell, but the condition between ""

db.foo.find({"field1.field2":123},{"field1":{"$elemMatch":{"field2":123}}})

db.foo.update({"_id":3,"field1.field2":1},{"$set":{"field1.$.field2":2}})

Or if you mean to projections to show any fields, is equal to mongo shell

db.foo.find({"field1.field2":123},{"field1.field2":1, "_id":1})

他のヒント

projection (optional): a list of field names that should be returned in the result set or a dict specifying the fields to include or exclude. If projection is a list “_id” will always be returned. Use a dict to exclude fields from the result (e.g. projection={‘_id’: False}).

Find more from here

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top