summaryrefslogtreecommitdiff
path: root/src/data.rs
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2017-07-12 06:35:41 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2017-07-12 11:38:25 -0400
commitf177dcb7b98300634fdef408150a83e9f476d66d (patch)
treeacc38470b061a3ff1bec8440d1957226dbfb22e6 /src/data.rs
parent80f1ddbe1e80682edd2d85b797a4d90ae4fc6f10 (diff)
add: Voting function
Diffstat (limited to 'src/data.rs')
-rw-r--r--src/data.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/data.rs b/src/data.rs
index ba821cc..c12db94 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -68,6 +68,17 @@ pub fn new_quote(c: &Connection, date: &str, author: &str, content: &str) -> Res
Ok(())
}
+pub fn new_vote(c: &Connection, quote_id: i64, score: i32) -> Result<()>{
+ c.execute(
+ r#"
+ INSERT INTO votes (quote_id, score) VALUES
+ (?1, ?2)
+ "#,
+ &[&quote_id, &score])?;
+ info!("New vote: quote_id({}) score({})", quote_id, score);
+ Ok(())
+}
+
pub fn approve_quote(c: &Connection, quote_id: i64) -> Result<()> {
c.execute(
r#"