I want projection in mongoengine raw query , here is my query but it don't works
query = {'$or':[{'col1':{'$regex':srch_text}},{'col2':{'$regex':srch_text}},{'col3':{'$regex':srch_text}}]}
projection = {'col4':0}
test= Test.objects(__raw__=(query,projection))
p.s : without projection it works
test= Test.objects(__raw__=(query))
__raw__
doesn't take a projection, so you should combine with only eg:
tests = Test.objects(__raw__=(query)).only('col4')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With