Fix small bugs in updating relays
This commit is contained in:
parent
e2cd84b136
commit
8b1affd8c7
3 changed files with 15 additions and 5 deletions
emgauwa-lib/src/db
|
@ -17,6 +17,7 @@ pub struct DbRelay {
|
|||
pub controller_id: i64,
|
||||
}
|
||||
|
||||
|
||||
impl DbRelay {
|
||||
pub async fn get_all(conn: &mut PoolConnection<Sqlite>) -> Result<Vec<DbRelay>, DatabaseError> {
|
||||
sqlx::query_as!(DbRelay, "SELECT * FROM relays")
|
||||
|
@ -152,4 +153,13 @@ impl DbRelay {
|
|||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn reload(
|
||||
&self,
|
||||
conn: &mut PoolConnection<Sqlite>,
|
||||
) -> Result<DbRelay, DatabaseError> {
|
||||
Self::get(conn, self.id)
|
||||
.await?
|
||||
.ok_or(DatabaseError::NotFound)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue