Implement models::instance::Instance::get

This commit is contained in:
Bat 2018-04-22 16:11:58 +01:00
parent f060fa08af
commit 4036d5771c
1 changed files with 6 additions and 2 deletions

View File

@ -43,8 +43,12 @@ impl Instance {
.expect("Error saving new instance")
}
pub fn get(id: i32) -> Option<Instance> {
None
pub fn get(conn: &PgConnection, id: i32) -> Option<Instance> {
instances::table.filter(instances::id.eq(id))
.limit(1)
.load::<Instance>(conn)
.expect("Error loading local instance infos")
.into_iter().nth(0)
}
pub fn block(&self) {}