pub struct QueryInterface<'l> { /* private fields */ }
Expand description

The query interface for a database.

As the query interface provides some level of caching, try to strive for as much sharing as possible. Passing around QueryInterface references instead of DB references is a good way to achieve this. However, QueryInterface is explicitly !Send, so you may need to use something like a DBPool to acquire instances locally if you’re using threads or asynchronous programming.

Implementations§

source§

impl<'l> QueryInterface<'l>

source

pub fn new(db: &'l DB) -> Self

Creates a QueryInterface. Generally you probably want to be using DBPool::query_interface().

source§

impl<'l> QueryInterface<'l>

source

pub fn insert<T: Entity + Serialize>( &self, m: &T ) -> Result<<T as Entity>::ID, Error>

Add an entity to its table in the database. Alias for add.

source

pub fn add<T: Entity + Serialize>( &self, m: &T ) -> Result<<T as Entity>::ID, Error>

Add an entity to its table in the database.

source§

impl<'l> QueryInterface<'l>

source

pub fn get<'a, 'b, T: Entity>(&'a self) -> Select<'b, 'l, T>
where 'a: 'b,

Get an entity from its table, aka perform a SELECT query.

source

pub fn update<'a, 'b, T: Entity>(&'a self) -> Update<'b, 'l, T>
where 'a: 'b,

Update an entity in its table, aka perform an UPDATE query, by selecting columns.

source

pub fn delete<'a, 'b, T: Entity>(&'a self) -> Delete<'b, 'l, T>
where 'a: 'b,

Delete an entity from its table, aka perform a DELETE query.

source§

impl<'l> QueryInterface<'l>

source

pub fn put<T: Entity>(&self, what: &WithID<T>) -> Result<(), Error>

Update an entity in its table, aka perform an UPDATE query, for all columns.

Auto Trait Implementations§

§

impl<'l> !RefUnwindSafe for QueryInterface<'l>

§

impl<'l> !Send for QueryInterface<'l>

§

impl<'l> !Sync for QueryInterface<'l>

§

impl<'l> Unpin for QueryInterface<'l>

§

impl<'l> !UnwindSafe for QueryInterface<'l>

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

§

type Output = T

Should always be Self
source§

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

§

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

§

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.