Can I pay a penalty for executing the request if I want to request the repeated property? For instance:
class User(ndb.Model): user_name = ndb.StringProperty() login_providers = ndb.KeyProperty(repeated=true) fbkey = ndb.Key("ProviderId", 1, "ProviderName", "FB") for entry in User.query(User.login_providers == fbkey):
vs
class User(ndb.Model) user_name = ndb.StringProperty() class UserProvider(ndb.Model): user_key = ndb.KeyProperty(kind=User) login_provider = ndb.KeyProperty() for entry in UserProvider.query( UserProvider.user_key == auserkey, UserProvider.login_provider == fbkey ): # Do something with entry.user_key
Based on the documentation from GAE, it seems that Datastore will take care of indexing, and the first less detailed option will use the index. However, I could not find any documentation supporting this.
Edit
The only purpose of UserProvider in the second example is to create a one-to-many relationship between the user and his login_provider. I would like to understand whether it is worth creating a second object instead of a query in the repeated property. Also, suppose that all I need is a key from User .
source share