Skip to main content

Store

Trait Store 

Source
pub trait Store:
    Send
    + Sync
    + 'static {
Show 16 methods // Required methods fn execute<'a>( &'a self, sql: &'a str, params: &'a [Value], ) -> BoxFuture<'a, Result<usize, StoreError>>; fn fetch<'a>( &'a self, sql: &'a str, params: &'a [Value], kinds: &'a [ColumnKind], ) -> BoxFuture<'a, Result<Rows, StoreError>>; fn scan_query<'a>( &'a self, schema: &'a Schema, query: &'a Query, ) -> BoxFuture<'a, Result<Rows, StoreError>>; fn total_query<'a>( &'a self, schema: &'a Schema, query: &'a Query, ) -> BoxFuture<'a, Result<usize, StoreError>>; fn define<'a>( &'a self, schema: &'a Schema, ) -> BoxFuture<'a, Result<(), StoreError>>; fn create<'a>( &'a self, schema: &'a Schema, batch: &'a [Vec<(Name, Value)>], ) -> BoxFuture<'a, Result<Vec<Key>, StoreError>>; fn replace<'a>( &'a self, schema: &'a Schema, key: &'a Key, cells: &'a [(Name, Value)], ) -> BoxFuture<'a, Result<(), StoreError>>; fn upsert<'a>( &'a self, schema: &'a Schema, batch: &'a [Vec<(Name, Value)>], ) -> BoxFuture<'a, Result<usize, StoreError>>; fn remove<'a>( &'a self, schema: &'a Schema, key: &'a Key, ) -> BoxFuture<'a, Result<(), StoreError>>; fn evolve<'a>( &'a self, schema: &'a Schema, drop: bool, ) -> BoxFuture<'a, Result<usize, StoreError>>; fn mass<'a>( &'a self, schema: &'a Schema, query: &'a Query, ) -> BoxFuture<'a, Result<Value, StoreError>>; fn last_id<'a>( &'a self, table: &'a str, ) -> BoxFuture<'a, Result<i64, StoreError>>; // Provided methods fn columns<'a>( &'a self, table: &'a str, ) -> BoxFuture<'a, Result<Vec<Column>, StoreError>> { ... } fn insert<'a>( &'a self, table: &'a str, columns: &'a [String], values: &'a [Value], ) -> BoxFuture<'a, Result<i64, StoreError>> { ... } fn deal<'a>(&'a self) -> BoxFuture<'a, Result<Arc<dyn Store>, StoreError>> { ... } fn settle( self: Arc<Self>, commit: bool, ) -> BoxFuture<'static, Result<(), StoreError>> { ... }
}
Expand description

A database backend: SQL and typed schema operations over a connection.

Required Methods§

Source

fn execute<'a>( &'a self, sql: &'a str, params: &'a [Value], ) -> BoxFuture<'a, Result<usize, StoreError>>

Runs sql with params, returning rows affected.

Source

fn fetch<'a>( &'a self, sql: &'a str, params: &'a [Value], kinds: &'a [ColumnKind], ) -> BoxFuture<'a, Result<Rows, StoreError>>

Runs sql with params, decoding rows per kinds.

Source

fn scan_query<'a>( &'a self, schema: &'a Schema, query: &'a Query, ) -> BoxFuture<'a, Result<Rows, StoreError>>

Fetches the rows of schema matching query.

Source

fn total_query<'a>( &'a self, schema: &'a Schema, query: &'a Query, ) -> BoxFuture<'a, Result<usize, StoreError>>

Counts the rows of schema matching query.

Source

fn define<'a>( &'a self, schema: &'a Schema, ) -> BoxFuture<'a, Result<(), StoreError>>

Creates schema’s table if absent.

Source

fn create<'a>( &'a self, schema: &'a Schema, batch: &'a [Vec<(Name, Value)>], ) -> BoxFuture<'a, Result<Vec<Key>, StoreError>>

Inserts a batch of schema rows, returning each new row’s key.

Source

fn replace<'a>( &'a self, schema: &'a Schema, key: &'a Key, cells: &'a [(Name, Value)], ) -> BoxFuture<'a, Result<(), StoreError>>

Overwrites key’s row of schema with cells.

Source

fn upsert<'a>( &'a self, schema: &'a Schema, batch: &'a [Vec<(Name, Value)>], ) -> BoxFuture<'a, Result<usize, StoreError>>

Inserts a schema batch, overwriting any matching keys, returning rows touched.

Source

fn remove<'a>( &'a self, schema: &'a Schema, key: &'a Key, ) -> BoxFuture<'a, Result<(), StoreError>>

Deletes key’s row of schema.

Source

fn evolve<'a>( &'a self, schema: &'a Schema, drop: bool, ) -> BoxFuture<'a, Result<usize, StoreError>>

Migrates schema’s table to the latest definition, returning statements run.

Source

fn mass<'a>( &'a self, schema: &'a Schema, query: &'a Query, ) -> BoxFuture<'a, Result<Value, StoreError>>

Aggregates schema rows matching query per query.mass.

Source

fn last_id<'a>( &'a self, table: &'a str, ) -> BoxFuture<'a, Result<i64, StoreError>>

Last autoincrement id inserted into table.

Provided Methods§

Source

fn columns<'a>( &'a self, table: &'a str, ) -> BoxFuture<'a, Result<Vec<Column>, StoreError>>

Introspects the columns of table.

Source

fn insert<'a>( &'a self, table: &'a str, columns: &'a [String], values: &'a [Value], ) -> BoxFuture<'a, Result<i64, StoreError>>

Raw single-row insert into table returning its id.

Source

fn deal<'a>(&'a self) -> BoxFuture<'a, Result<Arc<dyn Store>, StoreError>>

Opens a transaction as an independent Store.

Source

fn settle( self: Arc<Self>, commit: bool, ) -> BoxFuture<'static, Result<(), StoreError>>

Commits or rolls back the transaction from Store::deal.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§