sea-orm-relations-kit 0.1.0

Laravel-style relations for SeaORM: polymorphic relations, many-to-many attach/sync/toggle, relation counts and latest-of-many
Documentation
//! Relations for [SeaORM](https://www.sea-ql.org/SeaORM/) that it does not have out of
//! the box, with the operations that make them practical.
//!
//! - **Polymorphic relations**, where a child row points at an owner that can be one of
//!   several entities (`commentable_type` + `commentable_id`): [`Morph`] for one-to-one
//!   and one-to-many, with the child resolving its owner through [`morph_target!`];
//!   [`MorphToMany`] for many-to-many through a pivot; [`Morphable`] names each owner
//!   entity.
//! - **Pivot operations** for polymorphic and plain ([`BelongsToMany`]) many-to-many:
//!   `attach`, `detach`, `sync`, `sync_without_detaching`, `toggle`,
//!   `update_pivot`, ordered pivots and extra pivot columns.
//! - **Eager loading and counts** without N+1: `load_for`, `count_for`.
//! - **For `SeaORM`'s own relations** (anything with `Related<R>`): [`count_related`],
//!   [`exists_related`], [`aggregate_related`] (sum, average, min, max) and one row per
//!   owner by a column ([`latest_of_many`], [`oldest_of_many`], [`of_many`]).
//! - **Filters** as conditions for any query: owners that have (or lack) matching
//!   related rows, children whose owner matches a query, owners with all given keys.
//! - **Migrations**: [`schema`] builds the polymorphic columns and their index.
//!
//! Batch methods put the owners' keys in one `IN (...)` list; pass a page of rows,
//! not a whole table (Postgres allows 65 535 bind parameters per query).
//!
//! Polymorphic columns cannot have a foreign key, so the database cannot clean up
//! after a deleted owner. Call `delete_for` / `detach_all` in the owner's delete hook,
//! or `delete_orphans` from a scheduled task.

mod key;
mod morph;
mod of_many;
mod pivot;
mod related;
pub mod schema;
mod target;

pub use key::Key;
pub use morph::{Morph, Morphable};
pub use of_many::Pick;
pub use pivot::{BelongsToMany, Changes, MorphToMany, Morphed, PivotOwner, PivotRelation, Plain};
pub use related::{
    aggregate_related, count_related, count_related_with, exists_related, latest_of_many, of_many,
    oldest_of_many, Aggregate,
};
pub use target::MorphTarget;

/// Used by [`morph_target!`]; not part of the public API.
#[doc(hidden)]
pub mod __private {
    pub use crate::target::{find_by_keys, unknown_type};
    pub use sea_orm::{ConnectionTrait, DbErr, EntityTrait, Value};
}