pub struct DocEngine { /* private fields */ }Expand description
Document engine with collection-local dictionaries and packed docs.
Implementations§
Source§impl DocEngine
impl DocEngine
Sourcepub fn create_collection(
&mut self,
name: &str,
config: CollectionConfig,
) -> Result<CollectionId, DocError>
pub fn create_collection( &mut self, name: &str, config: CollectionConfig, ) -> Result<CollectionId, DocError>
Create a collection.
Sourcepub fn drop_collection(&mut self, name: &str) -> bool
pub fn drop_collection(&mut self, name: &str) -> bool
Drop a collection and all its documents.
Sourcepub fn collection_info(&self, name: &str) -> Option<CollectionInfo>
pub fn collection_info(&self, name: &str) -> Option<CollectionInfo>
Return collection info when present.
Sourcepub fn dictionary_info(&self, name: &str) -> Result<DictionaryInfo, DocError>
pub fn dictionary_info(&self, name: &str) -> Result<DictionaryInfo, DocError>
Return dictionary statistics for one collection.
Sourcepub fn storage_info(&self, name: &str) -> Result<StorageInfo, DocError>
pub fn storage_info(&self, name: &str) -> Result<StorageInfo, DocError>
Return packed storage statistics for one collection.
Sourcepub fn create_index(
&mut self,
collection: &str,
field_path: &str,
index_type: IndexType,
) -> Result<(), DocError>
pub fn create_index( &mut self, collection: &str, field_path: &str, index_type: IndexType, ) -> Result<(), DocError>
Create a secondary index on a collection field.
Backfills all existing documents. For Unique indexes, if a duplicate
value is detected during backfill the index is rolled back and an error
is returned.
Sourcepub fn drop_index(
&mut self,
collection: &str,
field_path: &str,
) -> Result<(), DocError>
pub fn drop_index( &mut self, collection: &str, field_path: &str, ) -> Result<(), DocError>
Remove a secondary index from a collection field.
Sourcepub fn indexes(
&self,
collection: &str,
) -> Result<Vec<(String, IndexType)>, DocError>
pub fn indexes( &self, collection: &str, ) -> Result<Vec<(String, IndexType)>, DocError>
Return all configured indexes for a collection.
Sourcepub fn set(
&mut self,
collection: &str,
external_doc_id: &str,
json: &Value,
) -> Result<SetResult, DocError>
pub fn set( &mut self, collection: &str, external_doc_id: &str, json: &Value, ) -> Result<SetResult, DocError>
Insert or replace one JSON document.
Sourcepub fn insert(
&mut self,
collection: &str,
json: &Value,
) -> Result<InsertResult, DocError>
pub fn insert( &mut self, collection: &str, json: &Value, ) -> Result<InsertResult, DocError>
Insert a document with an auto-generated ID.
Returns the generated ID and whether the document was newly created.
Sourcepub fn get(
&self,
collection: &str,
external_doc_id: &str,
projection: Option<&[&str]>,
) -> Result<Option<Value>, DocError>
pub fn get( &self, collection: &str, external_doc_id: &str, projection: Option<&[&str]>, ) -> Result<Option<Value>, DocError>
Get a full document or a projected subset of fields.
Sourcepub fn update(
&mut self,
collection: &str,
external_doc_id: &str,
mutations: &[DocMutation],
) -> Result<bool, DocError>
pub fn update( &mut self, collection: &str, external_doc_id: &str, mutations: &[DocMutation], ) -> Result<bool, DocError>
Apply field-level mutations to an existing document.
Returns Ok(true) when the document existed and was rewritten, Ok(false) when the
target document does not exist.
Sourcepub fn del(
&mut self,
collection: &str,
external_doc_id: &str,
) -> Result<bool, DocError>
pub fn del( &mut self, collection: &str, external_doc_id: &str, ) -> Result<bool, DocError>
Delete a document by external ID.
Sourcepub fn exists(
&self,
collection: &str,
external_doc_id: &str,
) -> Result<bool, DocError>
pub fn exists( &self, collection: &str, external_doc_id: &str, ) -> Result<bool, DocError>
Check whether a document exists.