Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoengine query projection

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))
like image 267
Beka Avatar asked Jan 14 '13 20:01

Beka


1 Answers

__raw__ doesn't take a projection, so you should combine with only eg:

tests = Test.objects(__raw__=(query)).only('col4')
like image 91
Ross Avatar answered Nov 07 '22 14:11

Ross