-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from JakenHerman/jaken/post-3
Add initial database for dooly
- Loading branch information
Showing
10 changed files
with
267 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
target/ | ||
target/ | ||
*.sqlite |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# For documentation on how to configure this file, | ||
# see https://diesel.rs/guides/configuring-diesel-cli | ||
|
||
[print_schema] | ||
file = "src/schema.rs" | ||
custom_type_derives = ["diesel::query_builder::QueryId", "Clone"] | ||
|
||
[migrations_directory] | ||
dir = "./migrations" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DROP TABLE todos; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
CREATE TABLE todos ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT, | ||
title TEXT NOT NULL, | ||
completed BOOLEAN NOT NULL DEFAULT 0 | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use diesel::prelude::*; | ||
use diesel::SqliteConnection; | ||
use rocket::serde::{Serialize, Deserialize}; | ||
|
||
use crate::schema::todos; | ||
|
||
#[derive(Queryable, Serialize, Deserialize)] | ||
pub struct TodoItem { | ||
pub id: i32, | ||
pub title: String, | ||
pub completed: bool, | ||
} | ||
|
||
#[derive(Insertable, Deserialize)] | ||
#[diesel(table_name = todos)] | ||
pub struct NewTodoItem<'a> { | ||
pub title: &'a str, | ||
pub completed: bool, | ||
} | ||
|
||
pub fn establish_connection() -> SqliteConnection { | ||
let database_url = "db.sqlite"; | ||
SqliteConnection::establish(&database_url).expect(&format!("Error connecting to {}", database_url)) | ||
} |
Oops, something went wrong.