Closed leonardwellthy closed 2 years ago
Running the tutorial example at https://graphene-mongo.readthedocs.io/en/latest/tutorial.html returns the following error
{ "errors": [ { "message": "'Cursor' object has no attribute 'count'", "locations": [ { "line": 2, "column": 3 } ], "path": [ "allEmployees" ] } ], "data": { "allEmployees": null } }
pymongo.cursor.Cursor.count() was deprecated in pymongo 3.7.0 and removed in pymongo 4.0. See the pymongo changelogs
pymongo.cursor.Cursor.count()
The following line in fields.py needs to be replaced with a call to pymongo.collection.Collection.count_documents
count = mongoengine.get_db()[self.model._get_collection_name()].find(args_copy).count()
pip install pymongo==3.12.0
yes, its working when line is changed to:
count = mongoengine.get_db()[self.model._get_collection_name()].count_documents(args_copy)
Error message
Running the tutorial example at https://graphene-mongo.readthedocs.io/en/latest/tutorial.html returns the following error
Underlying cause
pymongo.cursor.Cursor.count()
was deprecated in pymongo 3.7.0 and removed in pymongo 4.0. See the pymongo changelogsSolution
The following line in fields.py needs to be replaced with a call to pymongo.collection.Collection.count_documents
Temporary workaround
pip install pymongo==3.12.0