Trait aragog::Record[][src]

pub trait Record: DeserializeOwned + Serialize + Clone {
    fn collection_name() -> &'static str;
#[must_use] fn before_create_hook<'life0, 'life1, 'async_trait, D>(
        &'life0 mut self,
        db_accessor: &'life1 D
    ) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>>
    where
        D: DatabaseAccess,
        D: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn before_save_hook<'life0, 'life1, 'async_trait, D>(
        &'life0 mut self,
        db_accessor: &'life1 D
    ) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>>
    where
        D: DatabaseAccess,
        D: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn before_delete_hook<'life0, 'life1, 'async_trait, D>(
        &'life0 mut self,
        db_accessor: &'life1 D
    ) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>>
    where
        D: DatabaseAccess,
        D: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn after_create_hook<'life0, 'life1, 'async_trait, D>(
        &'life0 mut self,
        db_accessor: &'life1 D
    ) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>>
    where
        D: DatabaseAccess,
        D: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn after_save_hook<'life0, 'life1, 'async_trait, D>(
        &'life0 mut self,
        db_accessor: &'life1 D
    ) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>>
    where
        D: DatabaseAccess,
        D: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
;
#[must_use] fn after_delete_hook<'life0, 'life1, 'async_trait, D>(
        &'life0 mut self,
        db_accessor: &'life1 D
    ) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>>
    where
        D: DatabaseAccess,
        D: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
; #[must_use] fn find<'life0, 'life1, 'async_trait, D>(
        key: &'life0 str,
        db_accessor: &'life1 D
    ) -> Pin<Box<dyn Future<Output = Result<DatabaseRecord<Self>, ServiceError>> + Send + 'async_trait>>
    where
        D: DatabaseAccess,
        D: 'async_trait,
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: Send + 'async_trait
, { ... }
#[must_use] fn get<'life0, 'async_trait, D>(
        query: Query,
        db_accessor: &'life0 D
    ) -> Pin<Box<dyn Future<Output = Result<RecordQueryResult<Self>, ServiceError>> + Send + 'async_trait>>
    where
        D: DatabaseAccess,
        D: 'async_trait,
        'life0: 'async_trait,
        Self: Send + 'async_trait
, { ... }
#[must_use] fn exists<'life0, 'async_trait, D>(
        query: Query,
        db_accessor: &'life0 D
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
    where
        D: DatabaseAccess,
        D: 'async_trait,
        'life0: 'async_trait,
        Self: Send + 'async_trait
, { ... }
fn query() -> Query { ... }
fn transaction_builder() -> TransactionBuilder { ... }
#[must_use] fn transaction<'life0, 'async_trait>(
        db_pool: &'life0 DatabaseConnectionPool
    ) -> Pin<Box<dyn Future<Output = Result<Transaction, ServiceError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: Send + 'async_trait
, { ... } }

The main trait of the Aragog library. Trait for structures that can be stored in Database. The trait must be implemented to be used as a record in DatabaseRecord

Required methods

fn collection_name() -> &'static str[src]

returns the associated Collection for read and write operations.

#[must_use]fn before_create_hook<'life0, 'life1, 'async_trait, D>(
    &'life0 mut self,
    db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>> where
    D: DatabaseAccess,
    D: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

method called by DatabaseRecord::create before the database operation.

Define hooks manually or with macros (see the book)

#[must_use]fn before_save_hook<'life0, 'life1, 'async_trait, D>(
    &'life0 mut self,
    db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>> where
    D: DatabaseAccess,
    D: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

method called by DatabaseRecord::save before the database operation.

Define hooks manually or with macros (see the book)

#[must_use]fn before_delete_hook<'life0, 'life1, 'async_trait, D>(
    &'life0 mut self,
    db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>> where
    D: DatabaseAccess,
    D: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

method called by DatabaseRecord::delete before the database operation.

Define hooks manually or with macros (see the book)

#[must_use]fn after_create_hook<'life0, 'life1, 'async_trait, D>(
    &'life0 mut self,
    db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>> where
    D: DatabaseAccess,
    D: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

method called automatically by DatabaseRecord::create after the database operation.

Define hooks manually or with macros (see the book)

#[must_use]fn after_save_hook<'life0, 'life1, 'async_trait, D>(
    &'life0 mut self,
    db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>> where
    D: DatabaseAccess,
    D: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

method called automatically by DatabaseRecord::save after the database operation.

Define hooks manually or with macros (see the book)

#[must_use]fn after_delete_hook<'life0, 'life1, 'async_trait, D>(
    &'life0 mut self,
    db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<(), ServiceError>> + Send + 'async_trait>> where
    D: DatabaseAccess,
    D: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 
[src]

method called automatically by DatabaseRecord::delete after the database operation.

Define hooks manually or with macros (see the book)

Loading content...

Provided methods

#[must_use]fn find<'life0, 'life1, 'async_trait, D>(
    key: &'life0 str,
    db_accessor: &'life1 D
) -> Pin<Box<dyn Future<Output = Result<DatabaseRecord<Self>, ServiceError>> + Send + 'async_trait>> where
    D: DatabaseAccess,
    D: 'async_trait,
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: Send + 'async_trait, 
[src]

Finds a document in database from its unique key. Simple wrapper for DatabaseRecord<T>::find

#[must_use]fn get<'life0, 'async_trait, D>(
    query: Query,
    db_accessor: &'life0 D
) -> Pin<Box<dyn Future<Output = Result<RecordQueryResult<Self>, ServiceError>> + Send + 'async_trait>> where
    D: DatabaseAccess,
    D: 'async_trait,
    'life0: 'async_trait,
    Self: Send + 'async_trait, 
[src]

Finds all documents in database matching a Query. Simple wrapper for DatabaseRecord<T>::get

#[must_use]fn exists<'life0, 'async_trait, D>(
    query: Query,
    db_accessor: &'life0 D
) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>> where
    D: DatabaseAccess,
    D: 'async_trait,
    'life0: 'async_trait,
    Self: Send + 'async_trait, 
[src]

Returns true if there are any document in database matching a Query. Simple wrapper for DatabaseRecord<T>::exists

fn query() -> Query[src]

Creates a new Query instance for Self.

Example

#[derive(Record, Clone, Serialize, Deserialize)]
pub struct User { }

// All three statements are equivalent:
let q = User::query();
let q = Query::new(User::collection_name());
let q = Query::new("User");

fn transaction_builder() -> TransactionBuilder[src]

Returns a transaction builder on this collection only.

#[must_use]fn transaction<'life0, 'async_trait>(
    db_pool: &'life0 DatabaseConnectionPool
) -> Pin<Box<dyn Future<Output = Result<Transaction, ServiceError>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: Send + 'async_trait, 
[src]

Builds a transaction for this collection only.

Arguments

  • db_pool - The current database connection pool
Loading content...

Implementors

Loading content...