class DatabaseUser(database.Entity): # type: ignore """User ORM model""" id = PrimaryKey(UUID, default=uuid4) organization = Required("DatabaseOrganization") username = Required(str) password = Required(str) date_created = Required(datetime, default=datetime.utcnow) modified_at = Optional(datetime)
class User(db.Entity, UserMixin): login = Required(str, unique=True) password = Required(str) first_name = Required(str) last_name = Optional(str) created_at = Required(datetime, default=datetime.utcnow) last_login = Optional(datetime, default=datetime.utcnow) friends = Set('User', reverse='friends') sent = Set('Message', reverse='src') rcvd = Set('Message', reverse='dst') def check_password(self, password): return self.password == password def __str__(self): return ('%s %s' % (self.first_name, self.last_name)).rstrip()
class Mobile(db.Entity): uuid = PrimaryKey(uuid.UUID, default=uuid.uuid4) imei = Required(str) os_version = Required(str) device_version = Required(str) device_token = Required(str) public_key = Required(str) private_key = Required(str) ip = Required(str) def output(self): return { "uuid": self.uuid, "imei": self.imei, "os_version": self.os_version, "device_version": self.device_version, "device_token": self.device_token, "public_key": self.public_key, "private_key": self.private_key, "ip": self.ip }
class Artist(db.Entity): """ Artist table """ _table_ = "artist" id = PrimaryKey(int, auto=True) name = Required(str, max_len=512) country = Optional(str) location = Optional(str) image = Optional(str) age = Required(int, default=defaultAge) gender = Required(int, default=GenderEnum.MALE) isBand = Required(int, default=BandEnum.UNKOWN) status = Required(int, default=StatusEnum.ACTIVE) genre = Optional(str) lyricalThemes = Optional(str) currentLabel = Required(str, default="UNKOWN") FormedIn = Required(int, default=0) yearsActive = Optional(str) extra = Required(str, default="{}", max_len=4096) createTime = Required(datetime, default=datetime.today) lastModifiedTime = Required(datetime, default=datetime.today) lastOperator = Required(str, default="system") orm.composite_key(name, country)
class Car(db.Entity): make = Required(str) model = Required(str) owner = Required(Person)
class Person(db.Entity): name = Required(str) age = Required(int) cars = Set('Car')