class Users(ormar.Model): class Meta(BaseMeta): tablename = 'users' id: int = ormar.Integer(primary_key=True, unique=True, nullable=False) username: str = ormar.Text(unique=True, nullable=False) password: str = ormar.Text(nullable=False)
class Session(ormar.Model): class Meta: metadata = metadata database = database tablename = "test_sessions" id: int = ormar.Integer(primary_key=True) name: str = ormar.String(max_length=255, index=True) some_text: str = ormar.Text() some_other_text: Optional[str] = ormar.Text(nullable=True) students: Optional[List[User]] = ormar.ManyToMany(User, through=Signup)
class PrimaryModel(ormar.Model): class Meta: metadata = metadata database = db tablename = "primary_models" id: int = ormar.Integer(primary_key=True) name: str = ormar.String(max_length=255, index=True) some_text: str = ormar.Text() some_other_text: Optional[str] = ormar.Text(nullable=True) keywords: Optional[List[Keyword]] = ormar.ManyToMany( Keyword, through=KeywordPrimaryModel)
class Role(ormar.Model): class Meta(MainMeta): pass name: str = ormar.String(primary_key=True, max_length=1000) order: int = ormar.Integer(default=0, name="sort_order") description: str = ormar.Text()
class User(ormar.Model): class Meta(MainMeta): pass registrationnumber: str = ormar.Text(primary_key=True) company: Company = ormar.ForeignKey(Company) company2: Company = ormar.ForeignKey(Company)
class Author(ormar.Model): class Meta(BaseMeta): tablename = "authors" id: int = ormar.Integer(primary_key=True) name: str = ormar.String(max_length=100, **default_fernet) uuid_test = ormar.UUID(default=uuid.uuid4, uuid_format="string") uuid_test2 = ormar.UUID(nullable=True, uuid_format="string") password: str = ormar.String( max_length=128, encrypt_secret="udxc32", encrypt_backend=ormar.EncryptBackends.HASH, ) birth_year: int = ormar.Integer( nullable=True, encrypt_secret="secure89key%^&psdijfipew", encrypt_backend=ormar.EncryptBackends.FERNET, ) test_text: str = ormar.Text(default="", **default_fernet) test_bool: bool = ormar.Boolean(nullable=False, **default_fernet) test_float: float = ormar.Float(**default_fernet) test_float2: float = ormar.Float(nullable=True, **default_fernet) test_datetime = ormar.DateTime(default=datetime.datetime.now, **default_fernet) test_date = ormar.Date(default=datetime.date.today, **default_fernet) test_time = ormar.Time(default=datetime.time, **default_fernet) test_json = ormar.JSON(default={}, **default_fernet) test_bigint: int = ormar.BigInteger(default=0, **default_fernet) test_decimal = ormar.Decimal(scale=2, precision=10, **default_fernet) test_decimal2 = ormar.Decimal(max_digits=10, decimal_places=2, **default_fernet) custom_backend: str = ormar.String( max_length=200, encrypt_secret="asda8", encrypt_backend=ormar.EncryptBackends.CUSTOM, encrypt_custom_backend=DummyBackend, )
class UUIDSample(ormar.Model): class Meta: tablename = "uuids" metadata = metadata database = database id: uuid.UUID = ormar.UUID(primary_key=True, default=uuid.uuid4) test_text: str = ormar.Text()
class StripeSubscriptionPayment(ormar.Model): class Meta(BaseMeta): tablename = "stripe_subscription_payments" id: int = ormar.Integer(primary_key=True) payment: Payment = ormar.ForeignKey(Payment, nullable=False) stripe_subscription_id: str = ormar.String(max_length=256) stripe_invoice_id: str = ormar.String(max_length=256, unique=True) invoice_pdf: str = ormar.Text()
class Messages(ormar.Model): class Meta(BaseMeta): tablename = 'messages' id: int = ormar.Integer(primary_key=True, unique=True, nullable=False) user_id: int = ormar.Integer(nullable=False) chat_id: int = ormar.Integer(nullable=False) message_text: str = ormar.Text(nullable=False) date: str = ormar.DateTime(nullable=False)
class TradingPartner(ormar.Model): class Meta(BaseMeta): tablename = "tradingpartner" id = ormar.Integer(primary_key=True) nip_number = ormar.String(max_length=10) name = ormar.String(max_length=255) address = ormar.Text() enterprise_id = ormar.ForeignKey(Enterprise, ondelete="CASCADE")
class FilterXReport(ormar.Model): class Meta(ormar.ModelMeta): tablename = "filters_x_reports" database = database metadata = metadata filter_x_report_id = ormar.Integer(primary_key=True) filter = ormar.ForeignKey(Filter, name="filter_id", related_name="reports") report = ormar.ForeignKey(Report, name="report_id", related_name="filters") sort_order = ormar.Integer() default_value = ormar.Text() is_visible = ormar.Boolean()
class Human(ormar.Model): class Meta(BaseMeta): tablename = "humans" id: UUID = ormar.UUID(primary_key=True, default=uuid4) name: str = ormar.Text(default="") pets: List[Animal] = ormar.ManyToMany( Animal, related_name="care_takers", orders_by=["specie", "-name"], related_orders_by=["name"], )
class Example(ormar.Model): class Meta: tablename = "example" metadata = metadata database = database id: int = ormar.Integer(primary_key=True) name: str = ormar.String(max_length=200, default="aaa") created: datetime.datetime = ormar.DateTime(default=datetime.datetime.now) created_day: datetime.date = ormar.Date(default=datetime.date.today) created_time: datetime.time = ormar.Time(default=time) description: str = ormar.Text(nullable=True) value: float = ormar.Float(nullable=True) data: pydantic.Json = ormar.JSON(default={})
class User(ormar.Model): class Meta(BaseMeta): tablename = "user" id: int = ormar.Integer(primary_key=True, autoincrement=True, nullable=False) user: str = ormar.String( unique=True, index=True, nullable=False, max_length=255 ) # ID of the user on auth0 first: str = ormar.String(nullable=False, max_length=255) last: str = ormar.String(nullable=False, max_length=255) email: str = ormar.String(unique=True, index=True, nullable=False, max_length=255) display_name: str = ormar.String( unique=True, index=True, nullable=False, max_length=255 ) pic_url: str = ormar.Text(nullable=True)
class Chart(ormar.Model): class Meta(ormar.ModelMeta): tablename = "charts" database = database metadata = metadata chart_id = ormar.Integer(primary_key=True, autoincrement=True) name = ormar.String(max_length=200, unique=True, index=True) query_text = ormar.Text() datasets = ormar.JSON() layout = ormar.JSON() data_config = ormar.JSON() created_date = ormar.DateTime(server_default=func.now()) library = ormar.String(max_length=200, default="plotly") used_filters = ormar.JSON()
class Filter(ormar.Model): class Meta(ormar.ModelMeta): tablename = "filters" database = database metadata = metadata filter_id = ormar.Integer(primary_key=True, autoincrement=True) name = ormar.String(max_length=200, unique=True, index=True) label = ormar.String(max_length=200) query_text = ormar.Text() allow_multiselect = ormar.Boolean(default=True) created_date = ormar.DateTime(server_default=func.now()) is_dynamic = ormar.Boolean(default=True) is_date = ormar.Boolean(default=False) translation = ormar.ForeignKey(TranslationNode, name="translation_node_id")
class User(ormar.Model): class Meta(MainMeta): pass registrationnumber: str = ormar.String(primary_key=True, max_length=1000) company: Company = ormar.ForeignKey(Company) company2: Company = ormar.ForeignKey(Company, related_name="secondary_users") name: str = ormar.Text() role: Optional[Role] = ormar.ForeignKey(Role) roleforcompanies: Optional[Union[Company, List[Company]]] = ormar.ManyToMany( Company, through=UserRoleCompany, related_name="role_users") lastupdate: date = ormar.DateTime(server_default=sqlalchemy.func.now())
class ExampleModel(Model): class Meta: tablename = "example" metadata = metadata test: int = ormar.Integer(primary_key=True) test_string: str = ormar.String(max_length=250) test_text: str = ormar.Text(default="") test_bool: bool = ormar.Boolean(nullable=False) test_float: ormar.Float() = None # type: ignore test_datetime = ormar.DateTime(default=datetime.datetime.now) test_date = ormar.Date(default=datetime.date.today) test_time = ormar.Time(default=datetime.time) test_json = ormar.JSON(default={}) test_bigint: int = ormar.BigInteger(default=0) test_decimal = ormar.Decimal(scale=2, precision=10) test_decimal2 = ormar.Decimal(max_digits=10, decimal_places=2)