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

Method get_database

nodedb/src/control/security/catalog/database.rs:117–136  ·  view source on GitHub ↗

Get a database descriptor by id. Returns `None` if not found.

(&self, id: DatabaseId)

Source from the content-addressed store, hash-verified

115
116 /// Get a database descriptor by id. Returns `None` if not found.
117 pub fn get_database(&self, id: DatabaseId) -> crate::Result<Option<DatabaseDescriptor>> {
118 let txn = self
119 .db
120 .begin_read()
121 .map_err(|e| catalog_err("databases read txn", e))?;
122 let table = txn
123 .open_table(DATABASES)
124 .map_err(|e| catalog_err("open databases", e))?;
125 match table
126 .get(id.as_u64())
127 .map_err(|e| catalog_err("get databases", e))?
128 {
129 Some(v) => {
130 let desc: DatabaseDescriptor = zerompk::from_msgpack(v.value())
131 .map_err(|e| catalog_err("deser DatabaseDescriptor", e))?;
132 Ok(Some(desc))
133 }
134 None => Ok(None),
135 }
136 }
137
138 /// Resolve a database name to its `DatabaseId`. Returns `None` if
139 /// no database with that name exists.

Callers 15

put_then_get_roundtripFunction · 0.80
handle_alter_databaseFunction · 0.80
handle_clone_databaseFunction · 0.80
clone_chain_depthFunction · 0.80
handle_drop_databaseFunction · 0.80
handle_promote_databaseFunction · 0.80
execute_single_sqlMethod · 0.80
dispatch_task_innerMethod · 0.80

Calls 3

catalog_errFunction · 0.70
getMethod · 0.45
as_u64Method · 0.45