Skip to main content

NotebookDb

Trait NotebookDb 

Source
pub trait NotebookDb:
    Send
    + Sync
    + 'static {
    // Required methods
    fn list_by_owner<'life0, 'async_trait>(
        &'life0 self,
        owner_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Notebook>, DatabaseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn create<'life0, 'async_trait>(
        &'life0 self,
        owner_id: Uuid,
        name: String,
        cells: Value,
        deletable: bool,
    ) -> Pin<Box<dyn Future<Output = Result<Notebook, DatabaseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn create_seeded<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
        owner_id: Uuid,
        name: String,
        cells: Value,
        deletable: bool,
    ) -> Pin<Box<dyn Future<Output = Result<Notebook, DatabaseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn get_by_id_and_owner<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
        owner_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Notebook>, DatabaseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn update<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
        owner_id: Uuid,
        patch: NotebookUpdatePatch,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Notebook>, DatabaseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
    fn delete<'life0, 'async_trait>(
        &'life0 self,
        id: Uuid,
        owner_id: Uuid,
    ) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait;
}
Expand description

CRUD operations for the notebooks table.

Required Methods§

Source

fn list_by_owner<'life0, 'async_trait>( &'life0 self, owner_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Vec<Notebook>, DatabaseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Return all notebooks owned by owner_id, ordered by created_at asc.

Source

fn create<'life0, 'async_trait>( &'life0 self, owner_id: Uuid, name: String, cells: Value, deletable: bool, ) -> Pin<Box<dyn Future<Output = Result<Notebook, DatabaseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Insert a new notebook row and return it.

The implementation generates a fresh uuid4 id for the new row.

Source

fn create_seeded<'life0, 'async_trait>( &'life0 self, id: Uuid, owner_id: Uuid, name: String, cells: Value, deletable: bool, ) -> Pin<Box<dyn Future<Output = Result<Notebook, DatabaseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Insert a notebook with a caller-supplied id (used by the tutorial seeder to guarantee deterministic UUID5 ids across SDK restarts).

Source

fn get_by_id_and_owner<'life0, 'async_trait>( &'life0 self, id: Uuid, owner_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<Option<Notebook>, DatabaseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Fetch a notebook by id, scoped to the owner.

Source

fn update<'life0, 'async_trait>( &'life0 self, id: Uuid, owner_id: Uuid, patch: NotebookUpdatePatch, ) -> Pin<Box<dyn Future<Output = Result<Option<Notebook>, DatabaseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Apply a partial update. Returns the updated row or None when not found (ownership check included).

Source

fn delete<'life0, 'async_trait>( &'life0 self, id: Uuid, owner_id: Uuid, ) -> Pin<Box<dyn Future<Output = Result<bool, DatabaseError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

Delete a notebook. Returns true if a row was actually removed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§