How to build this query

34 views
Skip to first unread message

Moises Belchin

unread,
Nov 26, 2012, 4:08:06 AM11/26/12
to Google App Engine
Hi guys,

I want to query by a repeated property, Is there any way to build this kind of queries ??

ie:

class Orders(ndb.Model):
  clients = ndb.KeyProperty(indexed=True, default=None, repeated=True)

q = Orders.query(Orders.country == ndb.Key('Countries', 'US'),
                          Orders.clients == [])

Regards.
Moisés Belchín.

Kaan Soral

unread,
Nov 27, 2012, 3:31:09 PM11/27/12
to google-a...@googlegroups.com
you can do

q = Orders.query(Orders.country == ndb.Key('Countries', 'US'),
                          Orders.clients == 'client_id_etc')

but you can't query for non-existent things

you may add a seperate no_clients BooleanProperty etc and set it to True

so the answer to your question is, you can treat repeated properties as regular properties inside queries

if you read the docs, they explain these pretty well

Moises Belchin

unread,
Nov 28, 2012, 3:19:36 AM11/28/12
to Google App Engine
First of all, thanks for your answer.

In NDB you can query for non-existing things, ie: Orders.query(Orders.pending == None).fetch()

Just as you can query for None, I would ask for empty list.

I know you can create a ComputedProperty and query by this new property but I don't want to do this when the information, that I'm querying, is in my Repeated property.

My question is if there is any way to query by empty list.

Thanks again for comments.

Regards.


Saludos.
Moisés Belchín.



2012/11/27 Kaan Soral <kaan...@gmail.com>
--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-appengine/-/pRXDQTjOxqgJ.
To post to this group, send email to google-a...@googlegroups.com.
To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.

Reply all
Reply to author
Forward
0 new messages