[][src]Trait ormx::Table

pub trait Table where
    Self: Sized + Send + Sync + 'static, 
{ type Id: 'static + Copy + Send; fn id(&self) -> Self::Id;
fn get<'a, 'c: 'a>(
        db: impl Executor<'c, Database = Db> + 'a,
        id: Self::Id
    ) -> BoxFuture<'a, Result<Self>>;
fn stream_all<'a, 'c: 'a>(
        db: impl Executor<'c, Database = Db> + 'a
    ) -> BoxStream<'a, Result<Self>>;
fn stream_all_paginated<'a, 'c: 'a>(
        db: impl Executor<'c, Database = Db> + 'a,
        offset: i64,
        limit: i64
    ) -> BoxStream<'a, Result<Self>>;
fn update<'a, 'c: 'a>(
        &'a self,
        db: impl Executor<'c, Database = Db> + 'a
    ) -> BoxFuture<'a, Result<()>>;
fn delete<'a, 'c: 'a>(
        self,
        db: impl Executor<'c, Database = Db> + 'a
    ) -> BoxFuture<'a, Result<()>>; fn insert(
        db: &mut <Db as Database>::Connection,
        row: impl Insert<Table = Self>
    ) -> BoxFuture<'_, Result<Self>> { ... }
fn all<'a, 'c: 'a>(
        db: impl Executor<'c, Database = Db> + 'a
    ) -> BoxFuture<'a, Result<Vec<Self>>> { ... }
fn all_paginated<'a, 'c: 'a>(
        db: impl Executor<'c, Database = Db> + 'a,
        offset: i64,
        limit: i64
    ) -> BoxFuture<'a, Result<Vec<Self>>> { ... }
fn patch<'a, 'c: 'a, P>(
        &'a mut self,
        db: impl Executor<'c, Database = Db> + 'a,
        patch: P
    ) -> BoxFuture<'a, Result<()>>
    where
        P: Patch<Table = Self>
, { ... }
fn reload<'a, 'c: 'a>(
        &'a mut self,
        db: impl Executor<'c, Database = Db> + 'a
    ) -> BoxFuture<'a, Result<()>> { ... } }

A database table in which each row is identified by a unique ID.

Associated Types

type Id: 'static + Copy + Send

Type of the ID column of this table.

Loading content...

Required methods

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

Returns the id of this row.

fn get<'a, 'c: 'a>(
    db: impl Executor<'c, Database = Db> + 'a,
    id: Self::Id
) -> BoxFuture<'a, Result<Self>>

Queries the row of the given id.

fn stream_all<'a, 'c: 'a>(
    db: impl Executor<'c, Database = Db> + 'a
) -> BoxStream<'a, Result<Self>>

Stream all rows from this table.

fn stream_all_paginated<'a, 'c: 'a>(
    db: impl Executor<'c, Database = Db> + 'a,
    offset: i64,
    limit: i64
) -> BoxStream<'a, Result<Self>>

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

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

fn delete<'a, 'c: 'a>(
    self,
    db: impl Executor<'c, Database = Db> + 'a
) -> BoxFuture<'a, Result<()>>

Deletes this row from the database.

Loading content...

Provided methods

fn insert(
    db: &mut <Db as Database>::Connection,
    row: impl Insert<Table = Self>
) -> BoxFuture<'_, Result<Self>>

Insert a row into the database.

fn all<'a, 'c: 'a>(
    db: impl Executor<'c, Database = Db> + 'a
) -> BoxFuture<'a, Result<Vec<Self>>>

Load all rows from this table.

fn all_paginated<'a, 'c: 'a>(
    db: impl Executor<'c, Database = Db> + 'a,
    offset: i64,
    limit: i64
) -> BoxFuture<'a, Result<Vec<Self>>>

fn patch<'a, 'c: 'a, P>(
    &'a mut self,
    db: impl Executor<'c, Database = Db> + 'a,
    patch: P
) -> BoxFuture<'a, Result<()>> where
    P: Patch<Table = Self>, 

Applies a patch to this row.

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

Loading content...

Implementors

Loading content...