class User(AsyncModel, connection=ConnectionManager(DB_URI)): __tablename__ = 'users' id = Column(primary_key=True) name = Column() email = Column()
class WodResult(Entity): __tablename__ = 'wod_result' id = Column(default=uuid.uuid4, primary_key=True) wod_id = Column() user_id = Column() result = Column() sys_date = Column()
class Location(Entity): __tablename__ = 'location' user_id = Column(primary_key=True) longitude = Column() latitude = Column() locale = Column() tz = Column()
class WOD(Entity): __tablename__ = 'wod' id = Column(default=uuid.uuid4, primary_key=True) wod_day = Column() title = Column() description = Column() warmup = Column()
class UserModelMixin: __tablename__ = 'users' id = Column('_id', default=uuid.uuid4, primary_key=True) name = Column(default='test') email = Column() @classmethod async def populate(cls, n): for _ in range(n): name = random_string() email = f'{name}@example.com' model = cls(name=name, email=email) await model.save()
class DbModel(AsyncModel, connection=manager): """Base database model class that we inherit from. Adds the ``id`` column to all models that inherit from this class. The ``id`` in the database will be found at a column named ``_id``. """ id = Column('_id', default=uuid.uuid4, primary_key=True)
class User(DbModel): """A simple user class. Table Columns ------------- _id : uuid Primary Key name : text Not Null email : text """ # Set the database tablename. If not supplied then it defaults # to lower case version of class name. __tablename__ = 'users' name = Column() email = Column()
class User(Entity): __tablename__ = 'users' id = Column(default=uuid.uuid4, primary_key=True) user_id = Column() name = Column() surname = Column() lang = Column() admin = Column()
class Subscriber(Entity): __tablename__ = 'subscribers' id = Column(default=uuid.uuid4, primary_key=True) user_id = Column()