python - How to create mongoengine filter query from fields listed as string rather DocumentFields -


i trying write function can take filter query string , later want parse , create respective filter query used in mongoengine. tried using q() not working string.

working:

return q(id__istartswith=value) 

not working:

_query = 'id__istartswith=' + value return q(_query) 

any highly appreciated.

you can use keyword expansion.

_query = {'id__istartswith': value} return q(**_query) 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -