Sajjad Zaidi
Sajjad Zaidi

Reputation: 169

How can I fetch documents from a collection which contains a certain field using mongo engine

I want to fetch a document from a collection i.e Company which contains a certain field i.e Name. I have tried the following query but it does not work. Can somebody help me in correcting this query or maybe suggest a different query to get what I need? Thanks

Company.objects.get(name__isnull=False)

Upvotes: 1

Views: 147

Answers (1)

deadshot
deadshot

Reputation: 9051

You can use exists operator

Python.objects(name__exists=True)

Upvotes: 1

Related Questions