Skip to main content

DocumentEngine

Struct DocumentEngine 

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

The main document storage and query engine.

Implementations§

Source§

impl DocumentEngine

Source

pub fn new() -> Self

Create a new document engine with default configuration.

Source

pub fn with_config(config: EngineConfig) -> Self

Create a new document engine with custom configuration.

Source

pub fn create_collection( &self, name: impl Into<String>, ) -> Result<(), EngineError>

Create a new collection.

Source

pub fn create_collection_with_schema( &self, name: impl Into<String>, schema: Schema, ) -> Result<(), EngineError>

Create a collection with a schema.

Source

pub fn drop_collection(&self, name: &str) -> Result<(), EngineError>

Drop a collection.

Source

pub fn list_collections(&self) -> Vec<String>

List all collection names.

Source

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

Check if a collection exists.

Source

pub fn collection_stats(&self, name: &str) -> Option<CollectionStats>

Get collection statistics.

Source

pub fn insert( &self, collection: &str, doc: Document, ) -> Result<DocumentId, EngineError>

Insert a document into a collection.

Source

pub fn insert_many( &self, collection: &str, docs: Vec<Document>, ) -> Result<Vec<DocumentId>, EngineError>

Insert multiple documents.

Source

pub fn get( &self, collection: &str, id: &DocumentId, ) -> Result<Option<Document>, EngineError>

Get a document by ID.

Source

pub fn update( &self, collection: &str, id: &DocumentId, doc: Document, ) -> Result<(), EngineError>

Update a document.

Source

pub fn delete( &self, collection: &str, id: &DocumentId, ) -> Result<Document, EngineError>

Delete a document.

Source

pub fn find( &self, collection: &str, query: &Query, ) -> Result<QueryResult, EngineError>

Find documents matching a query.

Source

pub fn find_one( &self, collection: &str, query: &Query, ) -> Result<Option<Document>, EngineError>

Find one document matching a query.

Source

pub fn count( &self, collection: &str, query: &Query, ) -> Result<usize, EngineError>

Count documents matching a query.

Source

pub fn create_index( &self, collection: &str, field: impl Into<String>, index_type: IndexType, ) -> Result<(), EngineError>

Create an index on a collection field.

Source

pub fn drop_index( &self, collection: &str, field: &str, ) -> Result<(), EngineError>

Drop an index.

Source

pub fn list_indexes(&self, collection: &str) -> Result<Vec<String>, EngineError>

List indexes on a collection.

Source

pub fn stats(&self) -> EngineStats

Get engine statistics.

Source

pub fn reset_stats(&self)

Reset statistics.

Trait Implementations§

Source§

impl Default for DocumentEngine

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.