flask-mongorest
flask-mongorest copied to clipboard
How to return PyMongo cursor?
Hey there,
I have written the following code to return all documents in my collection.
class GetAll(Operator):
op = "test
def apply(self, queryset, field, value, negate=False):
collection = MetaboliteFull._get_collection().find({})
print collection.explain()
print collection.count()
return collection
Which returns...
{
"data": [],
"has_more": false
}
When I look at the query using the flask-debugtoolbar tool nothing obvious is given.
The output from the prints are...
{u'executionStats': {u'executionTimeMillis': 0, u'nReturned': 495, u'totalKeysExamined': 0, u'allPlansExecution': [], u'executionSuccess': True, u'executionStages': {u'needYield': 0, u'direction': u'forward', u'saveState': 3, u'restoreState': 3, u'isEOF': 1, u'docsExamined': 495, u'nReturned': 495, u'needTime': 1, u'filter': {u'$and': []}, u'executionTimeMillisEstimate': 0, u'invalidates': 0, u'works': 497, u'advanced': 495, u'stage': u'COLLSCAN'}, u'totalDocsExamined': 495}, u'queryPlanner': {u'parsedQuery': {u'$and': []}, u'rejectedPlans': [], u'namespace': u'dimedb.metabolites', u'winningPlan': {u'filter': {u'$and': []}, u'direction': u'forward', u'stage': u'COLLSCAN'}, u'indexFilterSet': False, u'plannerVersion': 1}, u'ok': 1.0, u'serverInfo': {u'host': u'think-big', u'version': u'3.2.12', u'port': 27017, u'gitVersion': u'ef3e1bc78e997f0d9f22f45aeb1d8e3b6ac14a14'}}
495
Is there something I'm missing?