THE ORIONIS API
Build with clarity.
Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.
class Model(AttributesMixin, StateMixin, RelationsMixin, EventsMixin, SoftDeletesMixin): (source)
Constructors: Model._newFromDatabase(row), Model.create(attributes), Model.findOrFail(key), Model.firstOrFail(), Model(attributes)
Base class of the Orionis active-record models.
Concrete models declare their columns with the fluent schema types and interact with the database exclusively through the Orionis query builder; the underlying SQL engine never surfaces. Class-level entry points such as where or orderBy start a builder implicitly.
| Class Method | _new |
Hydrate a model instance from a database row. |
| Class Method | add |
Register a constraint applied to every query of this model. |
| Async Class Method | all |
Retrieve every row of the model table. |
| Async Class Method | create |
Create, persist, and return a new model. |
| Async Class Method | destroy |
Delete the models matching the given primary keys. |
| Async Class Method | find |
Retrieve a model by its primary key. |
| Async Class Method | find |
Retrieve a model by primary key or raise when absent. |
| Async Class Method | first |
Retrieve the first row of the model table. |
| Async Class Method | first |
Retrieve the first row or raise when the table is empty. |
| Class Method | fresh |
Produce the current timestamp for persistence operations. |
| Class Method | get |
Resolve the connection configured for this model. |
| Class Method | new |
Produce a client-generated primary key value. |
| Class Method | query |
Start a new query builder bound to this model. |
| Class Method | remove |
Unregister a previously added global scope. |
| Method | __getattr__ |
Serve column values and accessor-backed attributes. |
| Method | __init__ |
Initialize a new, unsaved model instance. |
| Method | __repr__ |
Return a concise developer representation of the model. |
| Method | __setattr__ |
Route column assignments into the attribute store. |
| Async Method | _perform |
Remove the persisted row permanently. |
| Async Method | _perform |
Insert the model attributes as a new row. |
| Async Method | _perform |
Write the dirty attributes of an existing model. |
| Method | _primary |
Return the primary key value identifying the stored row. |
| Async Method | delete |
Delete the model row, honoring soft deletes when enabled. |
| Async Method | save |
Persist the model, inserting or updating as appropriate. |
| Async Method | update |
Mass assign the given attributes and persist the model. |
| Constant | CREATED |
Undocumented |
| Constant | DELETED |
Undocumented |
| Constant | UPDATED |
Undocumented |
| Class Variable | __abstract__ |
Undocumented |
| Class Variable | __meta__ |
Undocumented |
| Class Variable | __slots__ |
Undocumented |
| Class Variable | appends |
Undocumented |
| Class Variable | casts |
Undocumented |
| Class Variable | connection |
Undocumented |
| Class Variable | fillable |
Undocumented |
| Class Variable | guarded |
Undocumented |
| Class Variable | hidden |
Undocumented |
| Class Variable | incrementing |
Undocumented |
| Class Variable | primary |
Undocumented |
| Class Variable | soft |
Undocumented |
| Class Variable | table |
Undocumented |
| Class Variable | table |
Undocumented |
| Class Variable | timestamps |
Undocumented |
| Class Variable | uuids |
Undocumented |
| Instance Variable | _changes |
Undocumented |
| Instance Variable | _exists |
Undocumented |
Inherited from AttributesMixin:
| Method | exclude |
Return every attribute except the given keys. |
| Method | fill |
Mass assign the given attributes honoring the assignment rules. |
| Method | get |
Return a single attribute value through its accessor. |
| Method | has |
Report whether an attribute is served by an accessor. |
| Method | only |
Return a subset of attributes limited to the given keys. |
| Method | serialize |
Serialize the model for collection-level serialization. |
| Method | set |
Assign a single attribute applying its mutator and cast. |
| Method | to |
Serialize the visible attributes into a dictionary. |
| Method | to |
Serialize the visible attributes into a JSON string. |
Inherited from StateMixin (via AttributesMixin):
| Method | get |
Return the attributes persisted by the last save operation. |
| Method | get |
Return the attributes modified since the last sync. |
| Method | get |
Return the original attribute snapshot or a single original value. |
| Method | is |
Report whether no attribute changed since the last sync. |
| Method | is |
Report whether any attribute changed since the last sync. |
| Method | sync |
Snapshot the current attributes as the new original state. |
| Method | was |
Report whether the last save operation changed any attribute. |
Inherited from RelationsMixin (via AttributesMixin, StateMixin):
| Method | belongs |
Define the inverse of a hasOne/hasMany relationship. |
| Method | belongs |
Define a many-to-many relationship backed by a pivot table. |
| Method | get |
Return an already-resolved relationship result. |
| Method | has |
Define a one-to-many relationship owned by the related table. |
| Method | has |
Define a one-to-one relationship owned by the related table. |
| Method | relation |
Report whether a relationship result has already been resolved. |
| Method | set |
Store an already-resolved relationship result. |
Inherited from EventsMixin (via AttributesMixin, StateMixin, RelationsMixin):
| Class Method | flush |
Remove registered listeners from the model. |
| Class Method | observe |
Register every lifecycle method exposed by an observer. |
| Class Method | register |
Register a listener for a model lifecycle event. |
| Async Method | fire |
Dispatch a lifecycle event to its listeners. |
Inherited from SoftDeletesMixin (via AttributesMixin, StateMixin, RelationsMixin, EventsMixin):
| Async Method | _perform |
Stamp the soft delete column of the persisted row. |
| Async Method | force |
Delete the row permanently, ignoring soft deletes. |
| Async Method | restore |
Bring a soft deleted row back by clearing its delete stamp. |
| Method | trashed |
Report whether the instance is currently soft deleted. |
Create, persist, and return a new model.
| Parameters | |
attributes:dict | Attributes to mass assign honoring the fillable rules. |
| Returns | |
Model | Persisted model instance. |
| Raises | |
MassAssignmentException | If an attribute violates the mass assignment rules. |
QueryException | If the insert statement fails. |
Delete the models matching the given primary keys.
| Parameters | |
*keys:Any | Primary key values to delete. |
| Returns | |
int | Number of deleted rows. |
Retrieve a model by primary key or raise when absent.
| Parameters | |
key:Any | Primary key value to look up. |
| Returns | |
Model | Matching model. |
| Raises | |
ModelNotFoundException | If no record matches the key. |
Retrieve the first row or raise when the table is empty.
| Returns | |
Model | First model. |
| Raises | |
ModelNotFoundException | If the table has no rows. |
Produce the current timestamp for persistence operations.
Timezone-aware timestamps are produced when the update column is a timezone-aware type, naive UTC otherwise.
| Returns | |
datetime | Current UTC timestamp. |
Resolve the connection configured for this model.
| Returns | |
IConnection | Connection used for model queries and persistence. |
| Raises | |
OrmConfigurationException | If no connection manager has been installed. |
ConnectionNotFoundException | If the configured connection is not declared. |
Produce a client-generated primary key value.
Overridable by models needing a different identifier scheme, such as ULIDs or prefixed keys.
| Returns | |
Any | Fresh unique identifier. |
Start a new query builder bound to this model.
| Returns | |
ModelQueryBuilder | Fresh builder targeting the model table. |
Serve column values and accessor-backed attributes.
| Parameters | |
key:str | Attribute name being accessed. |
| Returns | |
Any | Attribute value; None for declared but unloaded columns. |
| Raises | |
AttributeError | If the name is neither loaded, a declared column, nor an accessor-backed attribute. |
Initialize a new, unsaved model instance.
| Parameters | |
attributes:dict or None, optional | Attributes to mass assign honoring the fillable rules. |
| Returns | |
None | This method does not return a value. |
| Raises | |
MassAssignmentException | If an attribute violates the mass assignment rules. |
Return a concise developer representation of the model.
| Returns | |
str | Representation including the class name and primary key. |
Remove the persisted row permanently.
| Returns | |
bool | True when a row was removed. |
| Raises | |
QueryException | If the statement fails to execute. |
Insert the model attributes as a new row.
| Returns | |
bool | True when the insert succeeds. |
| Raises | |
QueryException | If the statement fails to execute. |
Write the dirty attributes of an existing model.
| Returns | |
bool | True when a row was written or nothing changed, False when no stored row matched the primary key. |
| Raises | |
QueryException | If the statement fails to execute. |
Return the primary key value identifying the stored row.
The original value is preferred so a dirty primary key still targets the persisted row.
| Returns | |
Any | Primary key value. |
Delete the model row, honoring soft deletes when enabled.
Models declaring soft_deletes stamp their delete column instead of removing the row; every other model is deleted permanently.
| Returns | |
bool | True when a row was deleted or stamped, False for unsaved models or when a listener vetoed the operation. |
| Raises | |
QueryException | If the statement fails to execute. |
Persist the model, inserting or updating as appropriate.
New models are inserted, receiving their generated primary key; existing models write only their dirty attributes. Timestamps are maintained automatically when enabled, and the saving, creating/updating, created/updated and saved events are dispatched around the write.
| Returns | |
bool | True when the operation succeeds or nothing changed, False when a listener vetoed the write. |
| Raises | |
QueryException | If the statement fails to execute. |
Mass assign the given attributes and persist the model.
| Parameters | |
attributes:dict | Attributes to assign honoring the fillable rules. |
| Returns | |
bool | True when the operation succeeds or nothing changed. |
| Raises | |
MassAssignmentException | If an attribute violates the mass assignment rules. |
QueryException | If the statement fails to execute. |