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

Method get

nodedb/src/engine/document/store/engine/get.rs:10–29  ·  view source on GitHub ↗

Get a document and deserialize from MessagePack to JSON.

(&self, collection: &str, doc_id: &str)

Source from the content-addressed store, hash-verified

8impl<'a> DocumentEngine<'a> {
9 /// Get a document and deserialize from MessagePack to JSON.
10 pub fn get(&self, collection: &str, doc_id: &str) -> crate::Result<Option<serde_json::Value>> {
11 let bytes_opt = if self.is_bitemporal(collection) {
12 self.sparse
13 .versioned_get_current(self.tenant_id, collection, doc_id)?
14 } else {
15 self.sparse.get(self.tenant_id, collection, doc_id)?
16 };
17 match bytes_opt {
18 Some(bytes) => {
19 let rmpv_val = rmpv::decode::read_value(&mut bytes.as_slice()).map_err(|e| {
20 crate::Error::Serialization {
21 format: "msgpack".into(),
22 detail: format!("decode: {e}"),
23 }
24 })?;
25 Ok(Some(rmpv_to_json(&rmpv_val)))
26 }
27 None => Ok(None),
28 }
29 }
30
31 /// Get raw MessagePack bytes (zero-copy path for DataFusion UDFs).
32 pub fn get_raw(&self, collection: &str, doc_id: &str) -> crate::Result<Option<Vec<u8>>> {

Callers 9

navigate_jsonFunction · 0.45
is_bitemporalMethod · 0.45
put_and_get_documentFunction · 0.45
overwrite_documentFunction · 0.45
raw_msgpack_roundtripFunction · 0.45
collections_are_isolatedFunction · 0.45
deleteMethod · 0.45
put_rawMethod · 0.45
get_rawMethod · 0.45

Calls 5

versioned_get_currentMethod · 0.80
read_valueFunction · 0.50
rmpv_to_jsonFunction · 0.50
is_bitemporalMethod · 0.45
as_sliceMethod · 0.45

Tested by 4

put_and_get_documentFunction · 0.36
overwrite_documentFunction · 0.36
raw_msgpack_roundtripFunction · 0.36
collections_are_isolatedFunction · 0.36