pub struct DocumentEngine { /* private fields */ }Expand description
The main document storage and query engine.
Implementations§
Source§impl DocumentEngine
impl DocumentEngine
Sourcepub fn with_config(config: EngineConfig) -> Self
pub fn with_config(config: EngineConfig) -> Self
Create a new document engine with custom configuration.
Sourcepub fn create_collection(
&self,
name: impl Into<String>,
) -> Result<(), EngineError>
pub fn create_collection( &self, name: impl Into<String>, ) -> Result<(), EngineError>
Create a new collection.
Sourcepub fn create_collection_with_schema(
&self,
name: impl Into<String>,
schema: Schema,
) -> Result<(), EngineError>
pub fn create_collection_with_schema( &self, name: impl Into<String>, schema: Schema, ) -> Result<(), EngineError>
Create a collection with a schema.
Sourcepub fn drop_collection(&self, name: &str) -> Result<(), EngineError>
pub fn drop_collection(&self, name: &str) -> Result<(), EngineError>
Drop a collection.
Sourcepub fn list_collections(&self) -> Vec<String>
pub fn list_collections(&self) -> Vec<String>
List all collection names.
Sourcepub fn collection_exists(&self, name: &str) -> bool
pub fn collection_exists(&self, name: &str) -> bool
Check if a collection exists.
Sourcepub fn collection_stats(&self, name: &str) -> Option<CollectionStats>
pub fn collection_stats(&self, name: &str) -> Option<CollectionStats>
Get collection statistics.
Sourcepub fn insert(
&self,
collection: &str,
doc: Document,
) -> Result<DocumentId, EngineError>
pub fn insert( &self, collection: &str, doc: Document, ) -> Result<DocumentId, EngineError>
Insert a document into a collection.
Sourcepub fn insert_many(
&self,
collection: &str,
docs: Vec<Document>,
) -> Result<Vec<DocumentId>, EngineError>
pub fn insert_many( &self, collection: &str, docs: Vec<Document>, ) -> Result<Vec<DocumentId>, EngineError>
Insert multiple documents.
Sourcepub fn get(
&self,
collection: &str,
id: &DocumentId,
) -> Result<Option<Document>, EngineError>
pub fn get( &self, collection: &str, id: &DocumentId, ) -> Result<Option<Document>, EngineError>
Get a document by ID.
Sourcepub fn update(
&self,
collection: &str,
id: &DocumentId,
doc: Document,
) -> Result<(), EngineError>
pub fn update( &self, collection: &str, id: &DocumentId, doc: Document, ) -> Result<(), EngineError>
Update a document.
Sourcepub fn delete(
&self,
collection: &str,
id: &DocumentId,
) -> Result<Document, EngineError>
pub fn delete( &self, collection: &str, id: &DocumentId, ) -> Result<Document, EngineError>
Delete a document.
Sourcepub fn find(
&self,
collection: &str,
query: &Query,
) -> Result<QueryResult, EngineError>
pub fn find( &self, collection: &str, query: &Query, ) -> Result<QueryResult, EngineError>
Find documents matching a query.
Sourcepub fn find_one(
&self,
collection: &str,
query: &Query,
) -> Result<Option<Document>, EngineError>
pub fn find_one( &self, collection: &str, query: &Query, ) -> Result<Option<Document>, EngineError>
Find one document matching a query.
Sourcepub fn count(
&self,
collection: &str,
query: &Query,
) -> Result<usize, EngineError>
pub fn count( &self, collection: &str, query: &Query, ) -> Result<usize, EngineError>
Count documents matching a query.
Sourcepub fn create_index(
&self,
collection: &str,
field: impl Into<String>,
index_type: IndexType,
) -> Result<(), EngineError>
pub fn create_index( &self, collection: &str, field: impl Into<String>, index_type: IndexType, ) -> Result<(), EngineError>
Create an index on a collection field.
Sourcepub fn drop_index(
&self,
collection: &str,
field: &str,
) -> Result<(), EngineError>
pub fn drop_index( &self, collection: &str, field: &str, ) -> Result<(), EngineError>
Drop an index.
Sourcepub fn list_indexes(&self, collection: &str) -> Result<Vec<String>, EngineError>
pub fn list_indexes(&self, collection: &str) -> Result<Vec<String>, EngineError>
List indexes on a collection.
Sourcepub fn stats(&self) -> EngineStats
pub fn stats(&self) -> EngineStats
Get engine statistics.
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset statistics.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for DocumentEngine
impl RefUnwindSafe for DocumentEngine
impl Send for DocumentEngine
impl Sync for DocumentEngine
impl Unpin for DocumentEngine
impl UnsafeUnpin for DocumentEngine
impl UnwindSafe for DocumentEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more