I said what I wanted to say in the title. Strongly consistent is applied by using ancestor query.
from google.appengine.ext import ndb
class Customer(ndb.Model):
name = ndb.StringProperty()
class Purchase(ndb.Model):
price = ndb.IntegerProperty()
customer_entity = Customer(name='me', id='[email protected]')
purchase1 = Purchase(parent=customer_entity.key, price=100)
purchase2 = Purchase(parent=customer_entity.key, price=200)
purchase1.put()
purchase2.put()
print Purchase.query(ancestor=customer_entity.key).fetch()
#[Purchase(key=Key('Customer', '[email protected]', 'Purchase', 5414888608366592), price=200), Purchase(key=Key('Customer', '[email protected]', 'Purchase', 5977838561787904), price=100)]
key = ndb.Key('user', '[email protected]')
purchase3 = Purchase(parent=key, price=100)
purchase4 = Purchase(parent=key, price=200)
purchase3.put()
purchase4.put()
print Purchase.query(ancestor=key).fetch()
#[Purchase(key=Key('user', '[email protected]', 'Purchase', 4711201166589952), price=200), Purchase(key=Key('user', '[email protected]', 'Purchase', 6540788515209216), price=100)]
Recommended Posts