mirror of
https://github.com/mikedilger/chorus.git
synced 2026-02-02 06:25:12 +00:00
Store.get_event_by_id()
This commit is contained in:
parent
eb80f9d6ba
commit
4ee874acbb
@ -78,4 +78,14 @@ impl Store {
|
||||
pub fn get_event_by_offset(&self, offset: usize) -> Result<Option<Event>, Error> {
|
||||
self.events.get_event_by_offset(offset)
|
||||
}
|
||||
|
||||
/// Get an event by Id
|
||||
pub fn get_event_by_id(&self, id: Id) -> Result<Option<Event>, Error> {
|
||||
let txn = self.env.read_txn()?;
|
||||
if let Some(offset) = self.ids.get(&txn, id.0.as_slice())? {
|
||||
self.events.get_event_by_offset(offset)
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user