Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

How to return PyMongo cursor? #109

Open
KeironO opened this issue Apr 18, 2017 · 0 comments
Open

How to return PyMongo cursor? #109

KeironO opened this issue Apr 18, 2017 · 0 comments

Comments

@KeironO
Copy link

KeironO commented Apr 18, 2017

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?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant