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)
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)
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")
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)
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)
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)
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)
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)
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)
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")
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)
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)
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)
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")
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)
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)
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)
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)
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)
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)
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)
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)
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"))
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)
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]