Put a document (JSON value) into a collection.
(
&self,
collection: &str,
doc_id: &str,
document: &serde_json::Value,
)
| 10 | impl<'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( |