Insert or update a document within an externally-owned write transaction. Same prior-bytes semantics as [`SparseEngine::put`].
(
&self,
txn: &WriteTransaction,
tenant_id: u64,
collection: &str,
document_id: &str,
value: &[u8],
)
| 137 | /// Insert or update a document within an externally-owned write transaction. |
| 138 | /// Same prior-bytes semantics as [`SparseEngine::put`]. |
| 139 | pub fn put_in_txn( |
| 140 | &self, |
| 141 | txn: &WriteTransaction, |
| 142 | tenant_id: u64, |
| 143 | collection: &str, |
| 144 | document_id: &str, |
| 145 | value: &[u8], |
| 146 | ) -> crate::Result<Option<Vec<u8>>> { |
| 147 | with_tenant_key(tenant_id, collection, document_id, |key| { |
| 148 | let mut table = txn |
| 149 | .open_table(DOCUMENTS) |
| 150 | .map_err(|e| redb_err("open table", e))?; |
| 151 | let prior = table |
| 152 | .insert(key, value) |
| 153 | .map_err(|e| redb_err("insert", e))? |
| 154 | .map(|g| g.value().to_vec()); |
| 155 | Ok(prior) |
| 156 | }) |
| 157 | } |
| 158 | |
| 159 | /// Check whether a document exists within an externally-owned write |
| 160 | /// transaction — the probe used by INSERT-with-unique-PK semantics. |
no test coverage detected