pub trait Table{
type Id: 'static + Copy + Send;
// Required methods
fn id(&self) -> Self::Id;
fn get<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
id: Self::Id,
) -> impl Future<Output = Result<Self>> + Send + 'a;
fn stream_all<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
) -> impl Stream<Item = Result<Self>> + Send + 'a;
fn stream_all_paginated<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
offset: i64,
limit: i64,
) -> impl Stream<Item = Result<Self>> + Send + 'a;
fn update<'a, 'c: 'a>(
&'a self,
db: impl Executor<'c, Database = Db> + 'a,
) -> impl Future<Output = Result<()>> + Send + 'a;
// Provided methods
fn insert<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
row: impl Insert<Table = Self>,
) -> impl Future<Output = Result<Self>> + Send + 'a { ... }
fn all<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
) -> impl Future<Output = Result<Vec<Self>>> + Send + 'a { ... }
fn all_paginated<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
offset: i64,
limit: i64,
) -> impl Future<Output = Result<Vec<Self>>> + Send + 'a { ... }
fn patch<'a, 'c: 'a, P>(
&'a mut self,
db: impl Executor<'c, Database = Db> + 'a,
patch: P,
) -> impl Future<Output = Result<()>> + Send + 'a
where P: Patch<Table = Self> { ... }
fn reload<'a, 'c: 'a>(
&'a mut self,
db: impl Executor<'c, Database = Db> + 'a,
) -> impl Future<Output = Result<()>> + Send + 'a { ... }
}
Expand description
A database table in which each row is identified by a unique ID.
Required Associated Types§
Required Methods§
Sourcefn get<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
id: Self::Id,
) -> impl Future<Output = Result<Self>> + Send + 'a
fn get<'a, 'c: 'a>( db: impl Executor<'c, Database = Db> + 'a, id: Self::Id, ) -> impl Future<Output = Result<Self>> + Send + 'a
Queries the row of the given id.
Sourcefn stream_all<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
) -> impl Stream<Item = Result<Self>> + Send + 'a
fn stream_all<'a, 'c: 'a>( db: impl Executor<'c, Database = Db> + 'a, ) -> impl Stream<Item = Result<Self>> + Send + 'a
Stream all rows from this table.
By default, results are ordered in descending order according to their ID column.
This can be configured using #[ormx(order_by = "some_column ASC")]
.
Sourcefn stream_all_paginated<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
offset: i64,
limit: i64,
) -> impl Stream<Item = Result<Self>> + Send + 'a
fn stream_all_paginated<'a, 'c: 'a>( db: impl Executor<'c, Database = Db> + 'a, offset: i64, limit: i64, ) -> impl Stream<Item = Result<Self>> + Send + 'a
Streams at most limit
rows from this table, skipping the first offset
rows.
By default, results are ordered in descending order according to their ID column.
This can be configured using #[ormx(order_by = "some_column ASC")]
.
Provided Methods§
Sourcefn insert<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
row: impl Insert<Table = Self>,
) -> impl Future<Output = Result<Self>> + Send + 'a
fn insert<'a, 'c: 'a>( db: impl Executor<'c, Database = Db> + 'a, row: impl Insert<Table = Self>, ) -> impl Future<Output = Result<Self>> + Send + 'a
Insert a row into the database.
Sourcefn all<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
) -> impl Future<Output = Result<Vec<Self>>> + Send + 'a
fn all<'a, 'c: 'a>( db: impl Executor<'c, Database = Db> + 'a, ) -> impl Future<Output = Result<Vec<Self>>> + Send + 'a
Load all rows from this table.
By default, results are ordered in descending order according to their ID column.
This can be configured using #[ormx(order_by = "some_column ASC")]
.
Sourcefn all_paginated<'a, 'c: 'a>(
db: impl Executor<'c, Database = Db> + 'a,
offset: i64,
limit: i64,
) -> impl Future<Output = Result<Vec<Self>>> + Send + 'a
fn all_paginated<'a, 'c: 'a>( db: impl Executor<'c, Database = Db> + 'a, offset: i64, limit: i64, ) -> impl Future<Output = Result<Vec<Self>>> + Send + 'a
Load at most limit
rows from this table, skipping the first offset
.
By default, results are ordered in descending order according to their ID column.
This can be configured using #[ormx(order_by = "some_column ASC")]
.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.