Point lookup: retrieve a document by collection + document_id (tenant-scoped).
(
&self,
tenant_id: u64,
collection: &str,
document_id: &str,
)
| 227 | |
| 228 | /// Point lookup: retrieve a document by collection + document_id (tenant-scoped). |
| 229 | pub fn get( |
| 230 | &self, |
| 231 | tenant_id: u64, |
| 232 | collection: &str, |
| 233 | document_id: &str, |
| 234 | ) -> crate::Result<Option<Vec<u8>>> { |
| 235 | with_tenant_key(tenant_id, collection, document_id, |key| { |
| 236 | let read_txn = self.db.begin_read().map_err(|e| redb_err("read txn", e))?; |
| 237 | let table = read_txn |
| 238 | .open_table(DOCUMENTS) |
| 239 | .map_err(|e| redb_err("open table", e))?; |
| 240 | |
| 241 | match table.get(key) { |
| 242 | Ok(Some(value)) => Ok(Some(value.value().to_vec())), |
| 243 | Ok(None) => Ok(None), |
| 244 | Err(e) => Err(redb_err("get", e)), |
| 245 | } |
| 246 | }) |
| 247 | } |
| 248 | |
| 249 | /// Approximate byte count for all documents in a single |
| 250 | /// `(tenant_id, collection)` pair. Sums the raw value sizes via a |
no test coverage detected