MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / delete

Method delete

nodedb/src/engine/sparse/btree.rs:284–314  ·  view source on GitHub ↗

Delete a document (tenant-scoped). Returns the prior bytes when a row was actually removed, or `None` when nothing matched. The Event Plane needs the prior bytes as the `old_value` for CDC/trigger delete events; returning them here avoids a second read pass in the handler.

(
        &self,
        tenant_id: u64,
        collection: &str,
        document_id: &str,
    )

Source from the content-addressed store, hash-verified

282 /// `old_value` for CDC/trigger delete events; returning them here
283 /// avoids a second read pass in the handler.
284 pub fn delete(
285 &self,
286 tenant_id: u64,
287 collection: &str,
288 document_id: &str,
289 ) -> crate::Result<Option<Vec<u8>>> {
290 with_tenant_key(tenant_id, collection, document_id, |key| {
291 let write_txn = self
292 .db
293 .begin_write()
294 .map_err(|e| redb_err("write txn", e))?;
295 let prior = {
296 let mut table = write_txn
297 .open_table(DOCUMENTS)
298 .map_err(|e| redb_err("open table", e))?;
299 table
300 .remove(key)
301 .map_err(|e| redb_err("remove", e))?
302 .map(|g| g.value().to_vec())
303 };
304 write_txn.commit().map_err(|e| redb_err("commit", e))?;
305
306 debug!(
307 collection,
308 document_id,
309 removed = prior.is_some(),
310 "document delete"
311 );
312 Ok(prior)
313 })
314 }
315
316 /// Begin a write transaction on the underlying database.
317 pub fn begin_write(&self) -> crate::Result<WriteTransaction> {

Callers 15

build_routerFunction · 0.45
stub_routerFunction · 0.45
replay_vector_walMethod · 0.45
replay_kv_walMethod · 0.45
execute_vector_deleteMethod · 0.45
execute_bulk_deleteMethod · 0.45
execute_sparse_deleteMethod · 0.45
apply_actionFunction · 0.45

Calls 6

with_tenant_keyFunction · 0.85
begin_writeMethod · 0.80
redb_errFunction · 0.70
removeMethod · 0.45
to_vecMethod · 0.45
commitMethod · 0.45