ORIONIS API REFERENCE

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 documentation

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 _newFromDatabase Hydrate a model instance from a database row.
Class Method addGlobalScope 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 findOrFail 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 firstOrFail Retrieve the first row or raise when the table is empty.
Class Method freshTimestamp Produce the current timestamp for persistence operations.
Class Method getConnection Resolve the connection configured for this model.
Class Method newUniqueId Produce a client-generated primary key value.
Class Method query Start a new query builder bound to this model.
Class Method removeGlobalScope 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 _performForceDelete Remove the persisted row permanently.
Async Method _performInsert Insert the model attributes as a new row.
Async Method _performUpdate Write the dirty attributes of an existing model.
Method _primaryKeyValue 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_AT Undocumented
Constant DELETED_AT Undocumented
Constant UPDATED_AT 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_key Undocumented
Class Variable soft_deletes Undocumented
Class Variable table Undocumented
Class Variable table_definition 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 getAttribute Return a single attribute value through its accessor.
Method hasAccessor 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 setAttribute Assign a single attribute applying its mutator and cast.
Method toDict Serialize the visible attributes into a dictionary.
Method toJson Serialize the visible attributes into a JSON string.

Inherited from StateMixin (via AttributesMixin):

Method getChanges Return the attributes persisted by the last save operation.
Method getDirty Return the attributes modified since the last sync.
Method getOriginal Return the original attribute snapshot or a single original value.
Method isClean Report whether no attribute changed since the last sync.
Method isDirty Report whether any attribute changed since the last sync.
Method syncOriginal Snapshot the current attributes as the new original state.
Method wasChanged Report whether the last save operation changed any attribute.

Inherited from RelationsMixin (via AttributesMixin, StateMixin):

Method belongsTo Define the inverse of a hasOne/hasMany relationship.
Method belongsToMany Define a many-to-many relationship backed by a pivot table.
Method getRelation Return an already-resolved relationship result.
Method hasMany Define a one-to-many relationship owned by the related table.
Method hasOne Define a one-to-one relationship owned by the related table.
Method relationLoaded Report whether a relationship result has already been resolved.
Method setRelation Store an already-resolved relationship result.

Inherited from EventsMixin (via AttributesMixin, StateMixin, RelationsMixin):

Class Method flushEvents Remove registered listeners from the model.
Class Method observe Register every lifecycle method exposed by an observer.
Class Method registerEvent Register a listener for a model lifecycle event.
Async Method fireEvent Dispatch a lifecycle event to its listeners.

Inherited from SoftDeletesMixin (via AttributesMixin, StateMixin, RelationsMixin, EventsMixin):

Async Method _performSoftDelete Stamp the soft delete column of the persisted row.
Async Method forceDelete 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.
def _newFromDatabase(cls, row: dict[str, Any]) -> Model: (source)

Hydrate a model instance from a database row.

Parameters
row:dictRaw row values keyed by column name. The mapping is not shared with any other caller, so it is adopted and mutated in place instead of being copied.
Returns
ModelExisting model instance with casts applied.
def addGlobalScope(cls, name: str, scope: Callable[[ModelQueryBuilder[Any]], None]) -> type[Model]: (source)

Register a constraint applied to every query of this model.

Parameters
name:strName the scope is registered under, used to disable it later with withoutGlobalScope.
scope:CallableCallable receiving the builder and constraining it in place.
Returns
typeThe model class, enabling fluent chaining.
async def all(cls) -> Collection: (source)

Retrieve every row of the model table.

Returns
CollectionCollection of hydrated model instances.
async def create(cls, attributes: dict[str, Any]) -> Model: (source)

Create, persist, and return a new model.

Parameters
attributes:dictAttributes to mass assign honoring the fillable rules.
Returns
ModelPersisted model instance.
Raises
MassAssignmentExceptionIf an attribute violates the mass assignment rules.
QueryExceptionIf the insert statement fails.
async def destroy(cls, *keys: Any) -> int: (source)

Delete the models matching the given primary keys.

Parameters
*keys:AnyPrimary key values to delete.
Returns
intNumber of deleted rows.
async def find(cls, key: Any) -> Model | None: (source)

Retrieve a model by its primary key.

Parameters
key:AnyPrimary key value to look up.
Returns
Model or NoneMatching model, or None when absent.
async def findOrFail(cls, key: Any) -> Model: (source)

Retrieve a model by primary key or raise when absent.

Parameters
key:AnyPrimary key value to look up.
Returns
ModelMatching model.
Raises
ModelNotFoundExceptionIf no record matches the key.
async def first(cls) -> Model | None: (source)

Retrieve the first row of the model table.

Returns
Model or NoneFirst model, or None when the table is empty.
async def firstOrFail(cls) -> Model: (source)

Retrieve the first row or raise when the table is empty.

Returns
ModelFirst model.
Raises
ModelNotFoundExceptionIf the table has no rows.
def freshTimestamp(cls) -> datetime: (source)

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
datetimeCurrent UTC timestamp.
def getConnection(cls) -> IConnection: (source)

Resolve the connection configured for this model.

Returns
IConnectionConnection used for model queries and persistence.
Raises
OrmConfigurationExceptionIf no connection manager has been installed.
ConnectionNotFoundExceptionIf the configured connection is not declared.
def newUniqueId(cls) -> Any: (source)

Produce a client-generated primary key value.

Overridable by models needing a different identifier scheme, such as ULIDs or prefixed keys.

Returns
AnyFresh unique identifier.

Start a new query builder bound to this model.

Returns
ModelQueryBuilderFresh builder targeting the model table.
def removeGlobalScope(cls, name: str) -> type[Model]: (source)

Unregister a previously added global scope.

Parameters
name:strName the scope was registered under.
Returns
typeThe model class, enabling fluent chaining.
def __getattr__(self, key: str) -> Any: (source)

Serve column values and accessor-backed attributes.

Parameters
key:strAttribute name being accessed.
Returns
AnyAttribute value; None for declared but unloaded columns.
Raises
AttributeErrorIf the name is neither loaded, a declared column, nor an accessor-backed attribute.
def __init__(self, attributes: dict[str, Any] | None = None): (source)

Initialize a new, unsaved model instance.

Parameters
attributes:dict or None, optionalAttributes to mass assign honoring the fillable rules.
Returns
NoneThis method does not return a value.
Raises
MassAssignmentExceptionIf an attribute violates the mass assignment rules.
def __repr__(self) -> str: (source)

Return a concise developer representation of the model.

Returns
strRepresentation including the class name and primary key.
def __setattr__(self, key: str, value: Any): (source)

Route column assignments into the attribute store.

Parameters
key:strAttribute name being assigned.
value:AnyValue to assign.
Returns
NoneThis method does not return a value.
async def _performForceDelete(self) -> bool: (source)

Remove the persisted row permanently.

Returns
boolTrue when a row was removed.
Raises
QueryExceptionIf the statement fails to execute.
async def _performInsert(self) -> bool: (source)

Insert the model attributes as a new row.

Returns
boolTrue when the insert succeeds.
Raises
QueryExceptionIf the statement fails to execute.
async def _performUpdate(self) -> bool: (source)

Write the dirty attributes of an existing model.

Returns
boolTrue when a row was written or nothing changed, False when no stored row matched the primary key.
Raises
QueryExceptionIf the statement fails to execute.
def _primaryKeyValue(self) -> Any: (source)

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
AnyPrimary key value.
async def delete(self) -> bool: (source)

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
boolTrue when a row was deleted or stamped, False for unsaved models or when a listener vetoed the operation.
Raises
QueryExceptionIf the statement fails to execute.
async def save(self) -> bool: (source)

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
boolTrue when the operation succeeds or nothing changed, False when a listener vetoed the write.
Raises
QueryExceptionIf the statement fails to execute.
async def update(self, attributes: dict[str, Any]) -> bool: (source)

Mass assign the given attributes and persist the model.

Parameters
attributes:dictAttributes to assign honoring the fillable rules.
Returns
boolTrue when the operation succeeds or nothing changed.
Raises
MassAssignmentExceptionIf an attribute violates the mass assignment rules.
QueryExceptionIf the statement fails to execute.
CREATED_AT: ClassVar[str] = (source)

Undocumented

Value
'created_at'
DELETED_AT: ClassVar[str] = (source)

Undocumented

Value
'deleted_at'
UPDATED_AT: ClassVar[str] = (source)

Undocumented

Value
'updated_at'
__abstract__: bool = (source)

Undocumented

__meta__: ClassVar[ModelMetadata | None] = (source)

Undocumented

appends: ClassVar[list[str]] = (source)

Undocumented

casts: ClassVar[dict[str, str]] = (source)

Undocumented

connection: ClassVar[str | None] = (source)

Undocumented

fillable: ClassVar[list[str]] = (source)

Undocumented

guarded: ClassVar[list[str]] = (source)

Undocumented

hidden: ClassVar[list[str]] = (source)

Undocumented

incrementing: ClassVar[bool] = (source)

Undocumented

primary_key: ClassVar[str | None] = (source)

Undocumented

soft_deletes: ClassVar[bool] = (source)

Undocumented

table: ClassVar[str | None] = (source)

Undocumented

table_definition: ClassVar[TableDefinition | None] = (source)

Undocumented

timestamps: ClassVar[bool] = (source)

Undocumented

uuids: ClassVar[bool] = (source)

Undocumented

_changes = (source)

Undocumented

Undocumented