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§
Sourcefn get(
&self,
store: &str,
id: &str,
) -> impl Future<Output = Result<Option<Document>>> + Send
fn get( &self, store: &str, id: &str, ) -> impl Future<Output = Result<Option<Document>>> + Send
Fetch a document by id.
Sourcefn insert(
&self,
store: &str,
doc: &Document,
) -> impl Future<Output = Result<()>> + Send
fn insert( &self, store: &str, doc: &Document, ) -> impl Future<Output = Result<()>> + Send
Insert a new document (fails if the id already exists).
Sourcefn put(
&self,
store: &str,
doc: &Document,
) -> impl Future<Output = Result<()>> + Send
fn put( &self, store: &str, doc: &Document, ) -> impl Future<Output = Result<()>> + Send
Upsert a document by id.
Sourcefn delete(
&self,
store: &str,
id: &str,
) -> impl Future<Output = Result<bool>> + Send
fn delete( &self, store: &str, id: &str, ) -> impl Future<Output = Result<bool>> + Send
Delete a document by id. Returns whether a document was removed.
Sourcefn query(
&self,
store: &str,
options: QueryOptions,
) -> impl Future<Output = Result<QueryResult>> + Send
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.