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

class IBelongsToManyRelation(IRelation): (source)

Known subclasses: orionis.orm.relations.BelongsToManyRelation

View In Hierarchy

Contract for a many-to-many relationship backed by a pivot table.

Extends IRelation with the pivot-specific operations that have no equivalent on the single-table relationship kinds.

Async Method attach Link the parent to the given related records via the pivot table.
Async Method detach Unlink the parent from the given related records.
Async Method sync Attach exactly the given records, detaching every other one.
Async Method toggle Attach ids not currently linked, detach ids that already are.
Method wherePivot Filter the pivot rows considered by this relationship query.
Class Variable __slots__ Undocumented

Inherited from IRelation:

Method addConstraints Constrain the query to the bound parent instance.
Method addEagerConstraints Constrain the query to every parent instance of an eager batch.
Async Method getEager Execute the relationship query assembled for eager loading.
Async Method getResults Execute the relationship query for its bound parent instance.
Method match Group eager-loaded results and attach them to their parents.

Inherited from IModelQueryBuilder (via IRelation):

Async Method find Retrieve a model by its primary key.
Async Method findOrFail Retrieve a model by primary key or raise when absent.
Async Method first Execute the query and hydrate only the first matching row.
Async Method firstOrFail Return the first matching row or raise when none exists.
Async Method get Execute the query and hydrate every matching row.
Method load Eager load the given relationships; alias of withRelations.
Async Method paginate Execute the query returning a length-aware page of results.
Async Method pluck Return one column of every matching row.
Async Method value Return a single column value of the first matching row.
Method withRelations Eager load the given relationships alongside the query.

Inherited from IQueryBuilderBase (via IRelation, IModelQueryBuilder):

Method addSelect Append columns to the current projection.
Async Method avg Return the average value of a column among matching rows.
Method clone Return an independent copy of this builder.
Async Method count Count the rows matched by the query.
Method crossJoin Add a CROSS JOIN to the query.
Async Method delete Delete the rows matched by the query.
Method distinct Collapse duplicate rows from the query results.
Async Method doesntExist Report whether the query matches no rows.
Async Method exists Report whether the query matches at least one row.
Method forPage Limit the query to a single page of results.
Method fullJoin Add a FULL OUTER JOIN to the query.
Method groupBy Add grouping columns to the query.
Method having Add a post-grouping condition to the query.
Method havingRaw Add a raw SQL post-grouping condition.
Async Method insert Insert one or many rows into the target table.
Method join Add an INNER JOIN to the query.
Method joinSub Join a subquery as a derived table with an INNER JOIN.
Method latest Order the query by a timestamp column in descending order.
Method leftJoin Add a LEFT OUTER JOIN to the query.
Method leftJoinSub Join a subquery as a derived table with a LEFT OUTER JOIN.
Method limit Limit the number of rows returned by the query.
Method lockForUpdate Lock the selected rows against concurrent writes.
Async Method max Return the maximum value of a column among matching rows.
Async Method min Return the minimum value of a column among matching rows.
Method offset Skip the given number of rows before returning results.
Method oldest Order the query by a timestamp column in ascending order.
Method orderBy Add an ordering rule to the query.
Method orHaving Add an OR-combined post-grouping condition to the query.
Method orWhere Add an OR-combined filtering condition.
Method orWhereColumn Add an OR-combined comparison between two columns.
Method orWhereExists Add an OR-combined EXISTS condition.
Method orWhereIn Add an OR-combined set-membership condition.
Method orWhereNotExists Add an OR-combined NOT EXISTS condition.
Method orWhereNotIn Add an OR-combined set-exclusion condition.
Method orWhereNotNull Add an OR-combined IS NOT NULL condition.
Method orWhereNull Add an OR-combined IS NULL condition.
Method orWhereRaw Add an OR-combined raw SQL condition.
Method rightJoin Add a RIGHT OUTER JOIN to the query.
Method rightJoinSub Join a subquery as a derived table with a RIGHT OUTER JOIN.
Method select Restrict the query projection to the given columns.
Method selectRaw Append a raw SQL fragment to the projection.
Method selectSub Append a scalar subquery to the projection under an alias.
Method sharedLock Lock the selected rows in shared mode.
Method skip Skip the given number of rows; alias of offset.
Async Method sum Return the sum of a column among matching rows.
Method take Limit the number of rows returned; alias of limit.
Method toPlan Return the engine-agnostic plan assembled so far.
Method union Append another query's rows, collapsing duplicates.
Method unionAll Append another query's rows, keeping duplicates.
Async Method update Mass update the rows matched by the query.
Method where Add an AND-combined filtering condition.
Method whereBetween Filter rows whose column value lies between two boundaries.
Method whereColumn Compare two columns of the query against each other.
Method whereContains Filter rows whose column value contains the given text.
Method whereEndsWith Filter rows whose column value ends with the given text.
Method whereExists Keep rows for which a correlated subquery returns any row.
Method whereILike Filter rows matching a case-insensitive SQL LIKE pattern.
Method whereIn Filter rows whose column value belongs to the given set.
Method whereLike Filter rows whose column value matches an SQL LIKE pattern.
Method whereNotBetween Filter rows whose column value lies outside two boundaries.
Method whereNotExists Keep rows for which a correlated subquery returns no row.
Method whereNotILike Filter rows not matching a case-insensitive LIKE pattern.
Method whereNotIn Filter rows whose column value is outside the given set.
Method whereNotLike Filter rows not matching an SQL LIKE pattern.
Method whereNotNull Filter rows whose column value is not NULL.
Method whereNull Filter rows whose column value is NULL.
Method whereRaw Add an AND-combined raw SQL condition.
Method whereRegexpMatch Filter rows whose column value matches a regular expression.
Method whereStartsWith Filter rows whose column value starts with the given text.
async def attach(self, ids: Any, attributes: dict[str, Any] | None = None) -> int: (source)

Link the parent to the given related records via the pivot table.

Parameters
ids:AnyA related id, model instance, iterable of either, or a mapping of id to per-row pivot attributes.
attributes:dict or None, optionalExtra pivot column values applied to every inserted row when ids is not already a mapping.
Returns
intNumber of pivot rows inserted.
async def detach(self, ids: Any = None) -> int: (source)

Unlink the parent from the given related records.

Parameters
ids:Any, optionalA related id, model instance, or iterable of either; None detaches every related record.
Returns
intNumber of pivot rows deleted.
async def sync(self, ids: Iterable[Any]) -> dict[str, list[Any]]: (source)

Attach exactly the given records, detaching every other one.

Parameters
ids:IterableRelated ids or model instances that must remain attached.
Returns
dict of str to list"attached" and "detached" related id lists.
async def toggle(self, ids: Iterable[Any]) -> dict[str, list[Any]]: (source)

Attach ids not currently linked, detach ids that already are.

Parameters
ids:IterableRelated ids or model instances to toggle.
Returns
dict of str to list"attached" and "detached" related id lists.
def wherePivot(self, column: str, *args: Any) -> IBelongsToManyRelation: (source)

Filter the pivot rows considered by this relationship query.

Parameters
column:strPivot table column name.
*args:AnyEither the bound value, or an operator followed by a value.
Returns
IBelongsToManyRelationThe same relationship, enabling fluent chaining.