pub struct DB { /* private fields */ }Expand description
The main database handle for KotobaDB. This provides the user-facing API for database operations.
Implementations§
Source§impl DB
impl DB
Sourcepub fn open_memory() -> Result<Self>
pub fn open_memory() -> Result<Self>
Opens a new database instance using an in-memory storage engine. This is useful for testing, prototyping, or temporary data.
Sourcepub async fn begin_transaction(&self) -> Result<u64>
pub async fn begin_transaction(&self) -> Result<u64>
Begins a new transaction
Sourcepub async fn commit_transaction(&mut self, txn_id: u64) -> Result<()>
pub async fn commit_transaction(&mut self, txn_id: u64) -> Result<()>
Commits a transaction
Sourcepub async fn rollback_transaction(&mut self, txn_id: u64) -> Result<()>
pub async fn rollback_transaction(&mut self, txn_id: u64) -> Result<()>
Rolls back a transaction
Sourcepub async fn add_operation(
&self,
txn_id: u64,
operation: Operation,
) -> Result<()>
pub async fn add_operation( &self, txn_id: u64, operation: Operation, ) -> Result<()>
Adds an operation to a transaction
Sourcepub async fn create_edge(
&mut self,
label: String,
from_cid: Cid,
to_cid: Cid,
properties: BTreeMap<String, Value>,
) -> Result<Cid>
pub async fn create_edge( &mut self, label: String, from_cid: Cid, to_cid: Cid, properties: BTreeMap<String, Value>, ) -> Result<Cid>
Sourcepub async fn get_block(&self, cid: &Cid) -> Result<Option<Block>>
pub async fn get_block(&self, cid: &Cid) -> Result<Option<Block>>
Retrieves a block by its CID.
Sourcepub async fn get_node(&self, cid: &Cid) -> Result<Option<NodeBlock>>
pub async fn get_node(&self, cid: &Cid) -> Result<Option<NodeBlock>>
Retrieves a node by its CID.
Sourcepub async fn get_edge(&self, cid: &Cid) -> Result<Option<EdgeBlock>>
pub async fn get_edge(&self, cid: &Cid) -> Result<Option<EdgeBlock>>
Retrieves an edge by its CID.
Sourcepub async fn find_nodes(
&self,
filters: &[(String, Value)],
) -> Result<Vec<(Cid, NodeBlock)>>
pub async fn find_nodes( &self, filters: &[(String, Value)], ) -> Result<Vec<(Cid, NodeBlock)>>
Finds nodes that match the given property filters
Auto Trait Implementations§
impl Freeze for DB
impl !RefUnwindSafe for DB
impl Send for DB
impl Sync for DB
impl Unpin for DB
impl !UnwindSafe for DB
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