Skip to main content

DocumentStore

Trait DocumentStore 

Source
pub trait DocumentStore: Send + Sync {
    // Required methods
    fn get(
        &self,
        store: &str,
        id: &str,
    ) -> impl Future<Output = Result<Option<Document>>> + Send;
    fn insert(
        &self,
        store: &str,
        doc: &Document,
    ) -> impl Future<Output = Result<()>> + Send;
    fn put(
        &self,
        store: &str,
        doc: &Document,
    ) -> impl Future<Output = Result<()>> + Send;
    fn delete(
        &self,
        store: &str,
        id: &str,
    ) -> impl Future<Output = Result<bool>> + Send;
    fn query(
        &self,
        store: &str,
        options: QueryOptions,
    ) -> impl Future<Output = Result<QueryResult>> + Send;
}
Expand description

JSON document storage (WASI JSON DB).

Default WASM implementations delegate to wasi:jsondb via omnia-wasi-jsondb.

Required Methods§

Source

fn get( &self, store: &str, id: &str, ) -> impl Future<Output = Result<Option<Document>>> + Send

Fetch a document by id.

Source

fn insert( &self, store: &str, doc: &Document, ) -> impl Future<Output = Result<()>> + Send

Insert a new document (fails if the id already exists).

Source

fn put( &self, store: &str, doc: &Document, ) -> impl Future<Output = Result<()>> + Send

Upsert a document by id.

Source

fn delete( &self, store: &str, id: &str, ) -> impl Future<Output = Result<bool>> + Send

Delete a document by id. Returns whether a document was removed.

Source

fn query( &self, store: &str, options: QueryOptions, ) -> impl Future<Output = Result<QueryResult>> + Send

Query documents in a collection.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§