diff --git a/src/app/database.rs b/src/app/database.rs index c7cb8f6b..6318b57e 100644 --- a/src/app/database.rs +++ b/src/app/database.rs @@ -30,16 +30,21 @@ impl Database { } pub fn records(&self) -> Result, Error> { - let mut records: Vec = Vec::new(); - let mut statement = self.connection.prepare("SELECT `id`, `time` FROM `app`")?; - let _ = statement.query_map([], |row| { - records.push(Table { + + let result = statement.query_map([], |row| { + Ok(Table { id: row.get(0)?, time: row.get(1)?, - }); - Ok(()) - }); + }) + })?; + + let mut records: Vec
= Vec::new(); + + for record in result { + let table = record?; + records.push(table); + } Ok(records) }