示例#1
0
class Human2(ndb.Model):
    name = ndb.StringProperty("na", indexed=True)
    gender = ndb.msgprop.EnumProperty(Gender, "g", required=True, indexed=True)
    age = ndb.IntegerProperty("ag", indexed=False)
    items = ndb.StructuredProperty(Items, "i", required=True)
    numbers = ndb.JsonProperty('json', indexed=False)
    description = ndb.TextProperty("t", indexed=False)
    description2 = ndb.TextProperty("t2", compressed=True, indexed=False)
    meters_tall = ndb.FloatProperty("mtrs", indexed=False)
    datetime_of_birth = ndb.DateTimeProperty("dtb", indexed=False)
    date_of_birth = ndb.DateProperty("db", indexed=False)
    time_of_birth = ndb.TimeProperty("tb", indexed=False)
    hobbies = ndb.StringProperty('hob', repeated=True, indexed=False)
    pickle = ndb.PickleProperty('pi', indexed=False)
    binary = ndb.BlobProperty("bi", indexed=False)
    home = ndb.GeoPtProperty("ho", indexed=False)
    generic = ndb.GenericProperty("gen", indexed=False)
    model = ndb.LocalStructuredProperty(Items, "mo", indexed=False)
    person_details = ndb.msgprop.MessageProperty(person_pb2.Person, "pd")
    key_prop = ndb.KeyProperty(Department)
    key_prop2 = ndb.KeyProperty()

    number_of_hobbies = ndb.ComputedProperty(
        name="num_hob", func=lambda self: len(self.hobbies), indexed=False)
    default_info = ndb.StringProperty("di", indexed=False, default='unknown')
    update = ndb.DateTimeProperty("up", indexed=False, auto_now=True)

    def _pre_put_hook(self):
        pass
示例#2
0
class Foo(ndb.Model):
    # top-level model
    a = ndb.StructuredProperty(A, repeated=True)
示例#3
0
class A(ndb.Model):
    b = ndb.StructuredProperty(B)  #, required=True)