コード例 #1
0
ファイル: test_models.py プロジェクト: savostinn/ormantic
class User(orm.Model):
    id: orm.Integer(primary_key=True) = None
    name: orm.String(max_length=100)

    class Mapping:
        table_name = "users"
        metadata = metadata
        database = database
コード例 #2
0
class Organisation(orm.Model):
    id: orm.Integer(primary_key=True) = None
    ident: orm.String(max_length=100)

    class Mapping:
        table_name = "org"
        metadata = metadata
        database = database
コード例 #3
0
class Member(orm.Model):
    id: orm.Integer(primary_key=True) = None
    team: orm.ForeignKey(Team)
    email: orm.String(max_length=100)

    class Mapping:
        table_name = "member"
        metadata = metadata
        database = database
コード例 #4
0
class Team(orm.Model):
    id: orm.Integer(primary_key=True) = None
    org: orm.ForeignKey(Organisation)
    name: orm.String(max_length=100)

    class Mapping:
        table_name = "team"
        metadata = metadata
        database = database
コード例 #5
0
class Note(orm.Model):
    id: orm.Integer(primary_key=True) = None
    text: orm.String(max_length=100)
    completed: orm.Boolean() = False
    number: orm.Decimal(scale=6, precision=20, max_digits=13,
                        decimal_places=6) = '0'

    class Mapping:
        table_name = "notes"
        database = database
        metadata = metadata