luminadb.models packageο
Submodulesο
Module contentsο
Models
- class luminadb.models.BaseModel[source]ο
Bases:
objectBase class for all Models using Model API
- belongs_to(related_model: Type[T])[source]ο
Retrieve the related model that this instance belongs to.
- classmethod bulk_delete(keys: list[Any], key: str)[source]ο
Delete multiple records using a primary key.
- classmethod bulk_update(records: list[dict], key: str | object = <object object>)[source]ο
Update multiple records using a primary key or provided key.
- classmethod create_table(db: Database)[source]ο
Create table according to annotations and schema from __schema__
- classmethod find_or_fail(amount: int)[source]ο
Return models relative to the amount and when returned is equal to 0, throws an error
- classmethod first(**kwargs)[source]ο
Return the first matching record or None if no match is found.
- classmethod first_or_fail(**kwargs)[source]ο
Return the first matching record or raise an error if no match is found.
- has_many(related: ~typing.Type[~luminadb.models.T], foreign_key: str | object = <object object>)[source]ο
Ensure related_model has a Foreign key pointing to self
- has_one(related_model: Type[T])[source]ο
Retrieve the related model where this instance is referenced.
- classmethod one(**kwargs)[source]ο
Return exactly one record. Raises error if multiple results exist.
- class luminadb.models.Foreign(column: str, target: str | Type[Model])[source]ο
Bases:
ConstraintForeign constraint
- apply(type_: BuilderColumn)[source]ο
Apply this constraint to an column
- on_delete(constraint: ConstraintEnum)[source]ο
On delete constraint
- on_update(constraint: ConstraintEnum)[source]ο
On update constraint
- property targetο
Target foreign constraint
- class luminadb.models.Primary(column: str, auto: bool = False)[source]ο
Bases:
ConstraintPrimary constraint
Accepts optional auto flag to enable auto-increment on integer primary columns when using the BuilderColumn API.
- apply(type_: BuilderColumn)[source]ο
Apply this constraint as primary. If auto was requested, enable auto increment on the builder column as well.
- property auto: boolο
Auto increment
- class luminadb.models.QueryBuilder(model: Type[T])[source]ο
Bases:
Generic[T]Query builder for Model ORM
- update(**kwargs: Any)ο
Update a data based on the filter according to passed keyword args
- class luminadb.models.Unique(column: str)[source]ο
Bases:
ConstraintUnique constraint
- apply(type_: BuilderColumn)[source]ο
Apply this constraint to an column
- luminadb.models.hook(fn_or_name: Callable[[Model], None]) staticmethod[[Callable[[Model], None]], None][source]ο
- luminadb.models.hook(fn_or_name: str)
Register a hook