Trait Table

Source
pub trait Table
where Self: Sized + Send + Sync + 'static,
{ 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§

Source

type Id: 'static + Copy + Send

Type of the ID column of this table.

Required Methods§

Source

fn id(&self) -> Self::Id

Returns the id of this row.

Source

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.

Source

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")].

Source

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")].

Source

fn update<'a, 'c: 'a>( &'a self, db: impl Executor<'c, Database = Db> + 'a, ) -> impl Future<Output = Result<()>> + Send + 'a

Updates all fields of this row, regardless if they have been changed or not.

Provided Methods§

Source

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.

Source

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")].

Source

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")].

Source

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>,

Applies a patch to this row.

Source

fn reload<'a, 'c: 'a>( &'a mut self, db: impl Executor<'c, Database = Db> + 'a, ) -> impl Future<Output = Result<()>> + Send + 'a

Refresh this row, querying all columns from the database.

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.

Implementors§