aboutsummaryrefslogtreecommitdiff
path: root/src/db.rs
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-02-20 23:22:00 +0000
committerFuwn <[email protected]>2021-02-20 23:22:00 +0000
commitb1b29f1b6c91879838c8b01c4f5a3c4b7a86ec77 (patch)
treebf5e932b2ee8e0899743b4963375156ca13ceff0 /src/db.rs
parentchore, fix: refactor returns, grammar. (diff)
downloadchan-b1b29f1b6c91879838c8b01c4f5a3c4b7a86ec77.tar.xz
chan-b1b29f1b6c91879838c8b01c4f5a3c4b7a86ec77.zip
chore, fix, refactor: desc.
chore: - update readme fix: - grammer refactor: - undo previous commit return refactor
Diffstat (limited to 'src/db.rs')
-rw-r--r--src/db.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/db.rs b/src/db.rs
index f6d425e..11d35fb 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -28,13 +28,14 @@ pub fn _get_all_threads() -> Result<Vec<Thread>, SQLError> {
// Get all entries from the thread table.
let mut statement = db.prepare("SELECT board, name, comment FROM threads")?;
- statement.query_map(params![], |row| {
+ let threads = statement.query_map(params![], |row| {
Ok(Thread {
board: row.get(0)?,
name: row.get(1)?,
comment: row.get(2)?
})
- })?.collect()
+ })?;
+ threads.collect()
}
/// Get all boards from the SQLite database.
@@ -44,14 +45,15 @@ pub fn get_boards() -> Result<Vec<Board>, SQLError> {
// Get all entries from the thread table.
let mut statement = db.prepare("SELECT tag, name, nsfw, disabled FROM boards")?;
- statement.query_map(params![], |row| {
+ let boards = statement.query_map(params![], |row| {
Ok(Board {
tag: row.get(0)?,
name: row.get(1)?,
nsfw: row.get(2)?,
disabled: row.get(3)?
})
- })?.collect()
+ })?;
+ boards.collect()
}
/// Get all threads from a specific board within the SQLite database.
@@ -61,11 +63,12 @@ pub fn get_threads(board: String) -> Result<Vec<Thread>, SQLError> {
// Get all entries from the thread table.
let mut statement = db.prepare("SELECT board, name, comment FROM threads WHERE board = (?)")?;
- statement.query_map(params![board], |row| {
+ let threads = statement.query_map(params![board], |row| {
Ok(Thread {
board: row.get(0)?,
name: row.get(1)?,
comment: row.get(2)?
})
- })?.collect()
+ })?;
+ threads.collect()
}