Add last_tx_id.

This commit is contained in:
Nick Alexander 2018-05-02 15:38:12 -07:00
parent b9f3681728
commit 3744982cd9
2 changed files with 20 additions and 0 deletions

View file

@ -387,6 +387,11 @@ impl<'a, 'c> HasSchema for InProgress<'a, 'c> {
}
}
impl<'a, 'c> InProgressRead<'a, 'c> {
pub fn last_tx_id(&self) -> Entid {
self.0.last_tx_id()
}
}
impl<'a, 'c> InProgress<'a, 'c> {
pub fn builder(self) -> InProgressBuilder<'a, 'c> {
@ -526,6 +531,10 @@ impl<'a, 'c> InProgress<'a, 'c> {
},
}
}
pub fn last_tx_id(&self) -> Entid {
self.partition_map[":db.part/tx"].index - 1
}
}
struct InProgressTransactWatcher<'a, 'o> {
@ -617,6 +626,13 @@ impl Conn {
self.metadata.lock().unwrap().attribute_cache.clone()
}
pub fn last_tx_id(&self) -> Entid {
// The mutex is taken during this entire method.
let metadata = self.metadata.lock().unwrap();
metadata.partition_map[":db.part/tx"].index - 1
}
/// Query the Mentat store, using the given connection and the current metadata.
pub fn q_once<T>(&self,
sqlite: &rusqlite::Connection,

View file

@ -191,6 +191,10 @@ impl Store {
pub fn unregister_observer(&mut self, key: &String) {
self.conn.unregister_observer(key);
}
pub fn last_tx_id(&self) -> Entid {
self.conn.last_tx_id()
}
}
impl Queryable for Store {