For the following (broken) function, I want to return True
if the entity was created or updated, and False
otherwise. The problem is that I do not know whether get_or_insert()
got an existing entity, or inserted one. Is there an easy way to determine this?
class MyModel(ndb.Model):
def create_or_update(key, data):
"""Returns True if entity was created or updated, False otherwise."""
current = MyModel.get_or_insert(key, data=data)
if(current.data != data)
current.data = data
return True
return False
@classmethod
above@ndb.transactional
? Thanks – Cowden