Truncate: delete all entries in a KV collection. Returns count deleted.
(&mut self, tenant_id: u64, collection: &str)
| 89 | |
| 90 | /// Truncate: delete all entries in a KV collection. Returns count deleted. |
| 91 | pub fn truncate(&mut self, tenant_id: u64, collection: &str) -> usize { |
| 92 | let tkey = table_key(tenant_id, collection); |
| 93 | let count = self.tables.get(&tkey).map(|t| t.len()).unwrap_or(0); |
| 94 | |
| 95 | // Remove the hash table entirely. |
| 96 | self.tables.remove(&tkey); |
| 97 | // Remove all indexes. |
| 98 | self.indexes.remove(&tkey); |
| 99 | // Note: expiry wheel entries for this collection will be no-ops |
| 100 | // when they fire (key won't be found in the hash table). |
| 101 | |
| 102 | count |
| 103 | } |
| 104 | |
| 105 | // ----------------------------------------------------------------------- |
| 106 | // Stats |
no test coverage detected