Skip to main content

DocEngine

Struct DocEngine 

Source
pub struct DocEngine { /* private fields */ }
Expand description

Document engine with collection-local dictionaries and packed docs.

Implementations§

Source§

impl DocEngine

Source

pub fn new() -> Self

Create a document engine with packed format version 1.

Source

pub fn create_collection( &mut self, name: &str, config: CollectionConfig, ) -> Result<CollectionId, DocError>

Create a collection.

Source

pub fn drop_collection(&mut self, name: &str) -> bool

Drop a collection and all its documents.

Source

pub fn collection_info(&self, name: &str) -> Option<CollectionInfo>

Return collection info when present.

Source

pub fn dictionary_info(&self, name: &str) -> Result<DictionaryInfo, DocError>

Return dictionary statistics for one collection.

Source

pub fn storage_info(&self, name: &str) -> Result<StorageInfo, DocError>

Return packed storage statistics for one collection.

Source

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.

Source

pub fn drop_index( &mut self, collection: &str, field_path: &str, ) -> Result<(), DocError>

Remove a secondary index from a collection field.

Source

pub fn indexes( &self, collection: &str, ) -> Result<Vec<(String, IndexType)>, DocError>

Return all configured indexes for a collection.

Source

pub fn set( &mut self, collection: &str, external_doc_id: &str, json: &Value, ) -> Result<SetResult, DocError>

Insert or replace one JSON document.

Source

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.

Source

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.

Source

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.

Source

pub fn del( &mut self, collection: &str, external_doc_id: &str, ) -> Result<bool, DocError>

Delete a document by external ID.

Source

pub fn exists( &self, collection: &str, external_doc_id: &str, ) -> Result<bool, DocError>

Check whether a document exists.

Source

pub fn find( &self, collection: &str, where_clause: &str, projection: Option<&[&str]>, limit: Option<usize>, offset: usize, order_by: Option<&str>, order_desc: bool, ) -> Result<Vec<Value>, DocError>

Execute a WHERE query and return matching documents.

Source

pub fn count( &self, collection: &str, where_clause: &str, ) -> Result<u64, DocError>

Count documents matching a WHERE clause.

Trait Implementations§

Source§

impl Debug for DocEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DocEngine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.