I need to construct a logical query with a repeated property and can't get it to work. I have a list object with topics.
topics = [u'string1', u'string2', ...]
I have a query object:
videos = Video.query() videos.count() => 19
topics is a repeated string property
class Video topics = ndb.StringProperty(repeated=True)
I want to return videos that have a topic
string2. I also don't know the length of the list object before or I could just construct the query the long way with logical operators.
I tried doing this like the documentation suggests
videos.filter( Video.topics.IN([topics]) )
but that throws the error that IN expected a string not a list object.
How do I do this?google-app-engineapp-engine-ndbdjangoappengine
topics is already a list. So you need to pass it without another list around it:
videos.filter( Video.topics.IN(topics) )
For an arry of topics, you can use:
Or for a single string:
Video.query(Video.topics == topic)