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

Method put

nodedb/src/engine/document/store/engine/put.rs:12–31  ·  view source on GitHub ↗

Put a document (JSON value) into a collection.

(
        &self,
        collection: &str,
        doc_id: &str,
        document: &serde_json::Value,
    )

Source from the content-addressed store, hash-verified

10impl<'a> DocumentEngine<'a> {
11 /// Put a document (JSON value) into a collection.
12 pub fn put(
13 &self,
14 collection: &str,
15 doc_id: &str,
16 document: &serde_json::Value,
17 ) -> crate::Result<()> {
18 let msgpack = json_to_msgpack(document);
19 let mut buf = Vec::new();
20 rmpv::encode::write_value(&mut buf, &msgpack).map_err(|e| crate::Error::Serialization {
21 format: "msgpack".into(),
22 detail: format!("encode: {e}"),
23 })?;
24
25 // Delegate to put_raw so both JSON and raw-MessagePack entry points
26 // share the same bitemporal-aware write path.
27 self.put_raw(collection, doc_id, &buf)?;
28
29 let _ = document;
30 Ok(())
31 }
32
33 /// Put a document from raw MessagePack bytes.
34 pub fn put_raw(

Callers 8

put_and_get_documentFunction · 0.45
delete_documentFunction · 0.45
overwrite_documentFunction · 0.45
array_index_extractionFunction · 0.45
nested_field_indexFunction · 0.45
collections_are_isolatedFunction · 0.45
put_rawMethod · 0.45

Calls 2

json_to_msgpackFunction · 0.50
put_rawMethod · 0.45

Tested by 7

put_and_get_documentFunction · 0.36
delete_documentFunction · 0.36
overwrite_documentFunction · 0.36
array_index_extractionFunction · 0.36
nested_field_indexFunction · 0.36
collections_are_isolatedFunction · 0.36