Skip to content
Advertisement

How to construct pymongo query string from dictionary

My MongoDB documents looks like {'k1': 'v1', 'k2': 'v2', 'k3': 'v3' . . .}

Would like to construct a pymongo query string where Keys and Values in maDict are Match, gtDict are greater than and ltDict are less than and display only the fields specified in diDict:

JavaScript

I could think of converting each dictionary to construct the query string. Is there any better or shortcut method available to achieve

JavaScript

Advertisement

Answer

Thats how you can create your query:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement