Skip to main content

DbJoin

Struct DbJoin 

Source
pub struct DbJoin {
    pub offset: i64,
    pub limit: i64,
    pub sorting: Vec<String>,
    /* private fields */
}
Expand description

This struct is used to create a join between DbEntyty elements and JoinBuilder is used to create a DbJoin instance.

sorting parameter (such as vec![“data->>‘first_name’”, “data->>‘last_name’ DESC”]) take effect after a call to fetch method.

items can be persisted to db after a call to save_items method.

See JoinBuilder for more info

Fields§

§offset: i64

The offset of the extracted query join

§limit: i64

The limit of the extracted query join. If limit is negative it means “no limit”

§sorting: Vec<String>

Used to provide a sorting method on data fetching.

vec!["data->>'first_name'", "data->>'last_name' DESC"];

Implementations§

Source§

impl DbJoin

Source

pub async fn fetch<A>( &self, conn: &Connection, ) -> Result<Vec<DbEntity<A>>, DbError>
where A: DbData,

This method fetches items field for the given join using the current sorting field.

Source

pub async fn fetch_filtered<A>( &self, conn: &Connection, filter: (&str, &[&(dyn ToSql + Sync)]), ) -> Result<Vec<DbEntity<A>>, DbError>
where A: DbData,

This method fetches items field for the given join using the current sorting field. Filter is a tuple with the query filter and its values. The target table is aliased with “a” name so a query filter could be "a.data->>'name' LIKE $1"

Source

pub async fn add_items<A>( &self, conn: &mut Connection, items: &[&DbEntity<A>], ) -> Result<(), DbError>
where A: DbData,

This method adds items for the given join to the DB.

Source

pub async fn add_items_by_id( &self, conn: &mut Connection, items: &[&Uuid], ) -> Result<(), DbError>

This method adds items for the given join to the DB using object ids.

Source

pub async fn remove_items<A>( &self, conn: &mut Connection, items: Option<&[&DbEntity<A>]>, ) -> Result<(), DbError>
where A: DbData,

This method removes items for the given join to the DB.

Source

pub async fn remove_items_by_id( &self, conn: &mut Connection, items_id: Option<&[Uuid]>, ) -> Result<(), DbError>

This method removes items for the given join to the DB using object ids.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V