I use GAE NDB Python 2.7
My two Models code:
class A(ndb.Model):
def X(self, value):
:: # some statements to return a value
return range
def Y(self, value):
:: # some statements to return a value
return range
def Z(self, value):
:: # some statements to return a value
return range
property_1 = ndb.IntegerProperty(default=0, indexed=False)
property_2 = ndb.IntegerProperty(default=0, indexed=False)
property_3 = ndb.IntegerProperty(default=0, indexed=False)
property_4 = ndb.IntegerProperty(indexed=False)
# Computed values
computed_property_1 = ndb.ComputedProperty(lambda e: e.X(e.property_1))
computed_property_2 = ndb.ComputedProperty(lambda e: e.Y(e.property_2))
computed_property_3 = ndb.ComputedProperty(lambda e: e.Z(e.property_3))
date_added = ndb.DateTimeProperty(auto_now_add=True, indexed=False)
date_modified = ndb.DateTimeProperty(auto_now=True, indexed=False)
class B(ndb.Model):
property_5 = ndb.IntegerProperty()
property_6 = ndb.StructuredProperty(A)
date_added = ndb.DateTimeProperty(auto_now_add=True, indexed=False)
date_modified = ndb.DateTimeProperty(auto_now=True, indexed=False)
My Query code:
qry_1 = B.query(B.property_5==input_value) # or B.query(B.property_6.computed_property_2==input_value)
record_list = qry_1.fetch()
When I perform the above query on entity of model B, would any write operation be performed? (especially for the ComputedProperty and DateTimeProperty(with "auto_now") properties)
If yes, would it be rate limited to 1 write per second (i think that is the limit for free apps)
If yes, and if i have 50 entities matching the query, would it first complete the write operation(mentioned above) before completing the query and returning the matched entity set (any estimate of the query completion time)
Any difference in the above answers if I replace the following line in class B
property_6 = ndb.StructuredProperty(A)
with
property_6 = ndb.StructuredProperty(A, repeated=True)
There are no write operations by performing queries. The same applies to the two variations with StructuredProperty. Also
auto_now_add
andauto_now
are only set during write operations. I'm not 100% sure, but as far as I understand the docs, computed properties are also updated at write (I haven't used them yet).