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

Method delete

nodedb/src/engine/document/store/engine/delete.rs:13–50  ·  view source on GitHub ↗
(&self, collection: &str, doc_id: &str)

Source from the content-addressed store, hash-verified

11
12impl<'a> DocumentEngine<'a> {
13 pub fn delete(&self, collection: &str, doc_id: &str) -> crate::Result<bool> {
14 if self.is_bitemporal(collection) {
15 let prior_body =
16 self.sparse
17 .versioned_get_current(self.tenant_id, collection, doc_id)?;
18 let Some(body) = prior_body else {
19 return Ok(false);
20 };
21 let sys_from = wall_now_ms();
22 self.sparse
23 .versioned_tombstone(self.tenant_id, collection, doc_id, sys_from)?;
24 if let Some(config) = self.configs.get(collection)
25 && let Ok(rmpv_val) = rmpv::decode::read_value(&mut &body[..])
26 {
27 for index_path in &config.index_paths {
28 for v in
29 extract_index_values_rmpv(&rmpv_val, &index_path.path, index_path.is_array)
30 {
31 self.sparse.versioned_index_tombstone(
32 self.tenant_id,
33 collection,
34 &index_path.path,
35 &v,
36 doc_id,
37 sys_from,
38 )?;
39 }
40 }
41 }
42 return Ok(true);
43 }
44 self.sparse
45 .delete_indexes_for_document(self.tenant_id, collection, doc_id)?;
46 Ok(self
47 .sparse
48 .delete(self.tenant_id, collection, doc_id)?
49 .is_some())
50 }
51}

Callers

nothing calls this directly

Calls 9

versioned_get_currentMethod · 0.80
versioned_tombstoneMethod · 0.80
wall_now_msFunction · 0.70
read_valueFunction · 0.50
is_bitemporalMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected