Reputation: 613
I'm trying to do a query with projection in a GridFS like this:
Files = gridfs.GridFS(db)
f = Files.find({'metadata.AgentId': '1234'}, {'_id':1})
And i'm getting this error:
TypeError: skip must be an instance of int
So, the initializer for Cursor is taking {'_id':1} as the third parameter >> skip.
On the other hand, this query is working fine in the Robo3T shell:
Any idea?
Upvotes: 0
Views: 229
Reputation: 442
There is no projection
parameter in Gridfs.find
method.
https://api.mongodb.com/python/current/api/gridfs/index.html#gridfs.GridFS.find https://github.com/mongodb/mongo-python-driver/blob/master/gridfs/grid_file.py#L796-L802
Maybe you should use the collection's find. https://api.mongodb.com/python/current/api/pymongo/collection.html#pymongo.collection.Collection.find
db['fs.files'].find({'metadata.AgentId': '1234'}, {'_id':1})
Upvotes: 1