Esempio n. 1
0
class ModelTest2(ormar.Model):
    class Meta(BaseMeta):
        pass

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=200)
    url: HttpUrl = "https://www.example2.com"
    number: PaymentCardNumber = Field(default_factory=get_number)
Esempio n. 2
0
class Course(ormar.Model):
    class Meta:
        database = database
        metadata = metadata

    id: ormar.Integer(primary_key=True)
    name: ormar.String(max_length=100)
    completed: ormar.Boolean(default=False)
Esempio n. 3
0
class Book(ormar.Model):
    class Meta(BaseMeta):
        tablename = "books"

    id: int = ormar.Integer(primary_key=True)
    author: Optional[Author] = ormar.ForeignKey(Author)
    title: str = ormar.String(max_length=100)
    year: int = ormar.Integer(nullable=True)
    class RedefinedField(DateFieldsModel):
        class Meta(ormar.ModelMeta):
            tablename = "redefines"
            metadata = metadata
            database = db

        id: int = ormar.Integer(primary_key=True)
        created_date: str = ormar.String(max_length=200, name="creation_date")
Esempio n. 5
0
class Department(ormar.Model):
    class Meta:
        tablename = "departments"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True, autoincrement=False)
    name: str = ormar.String(max_length=100)
class Post(ormar.Model):
    class Meta(BaseMeta):
        pass

    id: int = ormar.Integer(primary_key=True)
    title: str = ormar.String(max_length=200)
    categories = ormar.ManyToMany(Category, skip_reverse=True)
    author: Optional[Author] = ormar.ForeignKey(Author, skip_reverse=True)
Esempio n. 7
0
class Author(ormar.Model):
    class Meta(BaseMeta):
        tablename = "authors"
        order_by = ["-name"]

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    publishers = ormar.ManyToMany(Publisher)
Esempio n. 8
0
class RandomSet(ormar.Model):
    class Meta:
        tablename = "randoms"
        metadata = metadata
        database = database

    id: int = ormar.Integer(name="random_id", primary_key=True)
    name: str = ormar.String(max_length=100)
Esempio n. 9
0
class Division(ormar.Model):
    class Meta:
        tablename = "divisions"
        metadata = metadata
        database = database

    id: int = ormar.Integer(name="division_id", primary_key=True)
    name: str = ormar.String(max_length=100, nullable=True)
Esempio n. 10
0
class ExampleModel2(Model):
    class Meta:
        tablename = "examples"
        metadata = metadata
        database = database

    test: int = ormar.Integer(primary_key=True)
    test_string: str = ormar.String(max_length=250)
Esempio n. 11
0
class Task(ormar.Model):
    class Meta(BaseMeta):
        tablename = "tasks"
        orders_by = ["-id"]

    id: int = ormar.Integer(primary_key=True, unique=True)
    name: str = ormar.String(max_length=100)
    completed: bool = ormar.Boolean(default=False)
Esempio n. 12
0
class VatRate(ormar.Model):
    class Meta(BaseMeta):
        tablename = "vatrate"

    id = ormar.Integer(primary_key=True)
    vat_rate = ormar.Float()
    comment = ormar.String(max_length=255)
    enterprise_id = ormar.ForeignKey(Enterprise, ondelete="CASCADE")
Esempio n. 13
0
class UserEnterprise(ormar.Model):
    class Meta(BaseMeta):
        tablename = "userenterprise"

    id = ormar.Integer(primary_key=True)
    enterprise_id = ormar.ForeignKey(Enterprise, ondelete="CASCADE")
    user_id = ormar.ForeignKey(User)
    role = ormar.String(max_length=10, choices=UserEnterpriseRoles)
Esempio n. 14
0
class Product(ormar.Model):
    class Meta(BaseMeta):
        tablename = "product"

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    rating: float = ormar.Float(minimum=1, maximum=5)
    category = ormar.ForeignKey(Category)
Esempio n. 15
0
class NickName(ormar.Model):
    class Meta(BaseMeta):
        tablename = "nicks"

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100, nullable=False, name="hq_name")
    is_lame: bool = ormar.Boolean(nullable=True)
    level: CringeLevel = ormar.ForeignKey(CringeLevel)
class User(ormar.Model):
    class Meta:
        metadata = metadata
        database = database
        tablename = "test_users"

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=50)
Esempio n. 17
0
class Company(ormar.Model):
    class Meta(BaseMeta):
        tablename = "companies"

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100, nullable=False, name="company_name")
    founded: int = ormar.Integer(nullable=True)
    hq: HQ = ormar.ForeignKey(HQ, related_name="companies")
Esempio n. 18
0
class AliasNested(ormar.Model):
    class Meta:
        tablename = "aliases_nested"
        metadata = metadata
        database = database

    id: int = ormar.Integer(name="alias_id", primary_key=True)
    name: str = ormar.String(name="alias_name", max_length=100)
Esempio n. 19
0
class Course(ormar.Model):
    class Meta(ormar.ModelMeta):  # note you don't have to subclass - but it's recommended for ide completion and mypy
        database = database
        metadata = metadata

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
    completed: bool = ormar.Boolean(default=False)
Esempio n. 20
0
class User(ormar.Model):
    class Meta:
        tablename = "users"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100, default="")
class SchoolClass(ormar.Model):
    class Meta:
        tablename = "schoolclasses"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
Esempio n. 22
0
class Writer(ormar.Model):
    class Meta:
        tablename = "writers"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
Esempio n. 23
0
        class WrongField2(DateFieldsModel):  # pragma: no cover
            class Meta(ormar.ModelMeta):
                tablename = "wrongs"
                metadata = metadata
                database = db

            id: int = ormar.Integer(primary_key=True)
            created_date: str = ormar.String(max_length=200)
Esempio n. 24
0
    class PostCategory(ormar.Model):
        class Meta(BaseMeta):
            tablename = "posts_x_categories"

        id: int = ormar.Integer(primary_key=True)
        sort_order: int = ormar.Integer(nullable=True)
        param_name: str = ormar.String(default="Name", max_length=200)
        blog = ormar.ForeignKey(Blog)
Esempio n. 25
0
class Category(ormar.Model):
    class Meta:
        tablename = "categories"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
Esempio n. 26
0
class Post(ormar.Model):
    class Meta(BaseMeta):
        pass

    id: int = ormar.Integer(primary_key=True)
    title: str = ormar.String(max_length=200)
    categories = ormar.ManyToMany(Category, through=PostCategory)
    blog = ormar.ForeignKey(Blog)
class Subject(ormar.Model):
    class Meta:
        tablename = "subjects"
        database = database
        metadata = metadata

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=80)
Esempio n. 28
0
class Post2(ormar.Model):
    class Meta(BaseMeta):
        pass

    id: int = ormar.Integer(primary_key=True)
    title: str = ormar.String(max_length=200)
    categories = ormar.ManyToMany(Category,
                                  through=ForwardRef("PostCategory2"))
Esempio n. 29
0
class CringeLevel(ormar.Model):
    class Meta:
        tablename = "levels"
        metadata = metadata
        database = database

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=100)
Esempio n. 30
0
class ModelTest(ormar.Model):
    class Meta(BaseMeta):
        pass

    id: int = ormar.Integer(primary_key=True)
    name: str = ormar.String(max_length=200)
    url: HttpUrl = "https://www.example.com"
    number: Optional[PaymentCardNumber]