diff options
author | metamuffin <metamuffin@disroot.org> | 2025-01-30 16:45:06 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-01-30 16:45:06 +0100 |
commit | bfc5552a8eba07897c2ed626b49c085d97fdfa0d (patch) | |
tree | 2eaff957b4a744e55710502c81f7ce38a3f86294 /base/src/database.rs | |
parent | 32a05b5ec244d4d8143993b082f8d3f86a0a4ecd (diff) | |
download | jellything-bfc5552a8eba07897c2ed626b49c085d97fdfa0d.tar jellything-bfc5552a8eba07897c2ed626b49c085d97fdfa0d.tar.bz2 jellything-bfc5552a8eba07897c2ed626b49c085d97fdfa0d.tar.zst |
external ids and urls
Diffstat (limited to 'base/src/database.rs')
-rw-r--r-- | base/src/database.rs | 22 |
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)?; |