aboutsummaryrefslogtreecommitdiff
path: root/base/src/database.rs
diff options
context:
space:
mode:
Diffstat (limited to 'base/src/database.rs')
-rw-r--r--base/src/database.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/base/src/database.rs b/base/src/database.rs
index cd8b2bc..28cafaa 100644
--- a/base/src/database.rs
+++ b/base/src/database.rs
@@ -56,11 +56,13 @@ impl Database {
{
// this creates all tables such that read operations on them do not fail.
let txn = r.inner.begin_write()?;
- drop(txn.open_table(T_INVITE)?);
- drop(txn.open_table(T_USER)?);
- drop(txn.open_table(T_USER_NODE)?);
- drop(txn.open_table(T_NODE)?);
- drop(txn.open_table(T_IMPORT_FILE_MTIME)?);
+ txn.open_table(T_INVITE)?;
+ txn.open_table(T_USER)?;
+ txn.open_table(T_USER_NODE)?;
+ txn.open_table(T_NODE)?;
+ txn.open_table(T_NODE_CHILDREN)?;
+ txn.open_table(T_NODE_EXTERNAL_ID)?;
+ txn.open_table(T_IMPORT_FILE_MTIME)?;
txn.commit()?;
}
@@ -81,7 +83,15 @@ impl Database {
Ok(None)
}
}
-
+ pub fn get_node_external_id(&self, platform: &str, eid: &str) -> Result<Option<NodeID>> {
+ let txn = self.inner.begin_read()?;
+ let t_node_external_id = txn.open_table(T_NODE_EXTERNAL_ID)?;
+ if let Some(id) = t_node_external_id.get((platform, eid))? {
+ Ok(Some(NodeID(id.value())))
+ } else {
+ Ok(None)
+ }
+ }
pub fn get_node_children(&self, id: NodeID) -> Result<Vec<NodeID>> {
let txn = self.inner.begin_read()?;
let t_node_children = txn.open_table(T_NODE_CHILDREN)?;