Update
This commit is contained in:
parent
ee2bfbb769
commit
653267344f
3 changed files with 10 additions and 12 deletions
|
@ -1,12 +1,12 @@
|
||||||
#[macro_use] extern crate diesel;
|
#[macro_use] extern crate diesel;
|
||||||
#[macro_use] extern crate diesel_migrations;
|
#[macro_use] extern crate diesel_migrations;
|
||||||
|
|
||||||
|
mod models;
|
||||||
|
|
||||||
use rocket::*;
|
use rocket::*;
|
||||||
use rocket::fairing::AdHoc;
|
use rocket::fairing::AdHoc;
|
||||||
use rocket_sync_db_pools::{database};
|
use rocket_sync_db_pools::{database};
|
||||||
|
|
||||||
mod task;
|
|
||||||
|
|
||||||
#[database("sqlite_logs")]
|
#[database("sqlite_logs")]
|
||||||
pub struct DbConn(diesel::SqliteConnection);
|
pub struct DbConn(diesel::SqliteConnection);
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ fn index() -> &'static str {
|
||||||
|
|
||||||
#[get("/log/<id>")]
|
#[get("/log/<id>")]
|
||||||
async fn get_log(conn: DbConn, id: i32) -> String {
|
async fn get_log(conn: DbConn, id: i32) -> String {
|
||||||
let result = task::Task::all(&conn).await;
|
let result = models::task::Task::all(&conn).await;
|
||||||
format!("test {}, {:?}", id, result)
|
format!("test {}, {:?}", id, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
1
src/models/mod.rs
Normal file
1
src/models/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod task;
|
|
@ -1,7 +1,6 @@
|
||||||
use rocket::serde::Serialize;
|
use rocket::serde::Serialize;
|
||||||
use diesel::{self, result::QueryResult, Queryable, Insertable, prelude::*};
|
use diesel::{self, result::QueryResult, Queryable, Insertable, prelude::*};
|
||||||
|
|
||||||
mod schema {
|
|
||||||
table! {
|
table! {
|
||||||
tasks {
|
tasks {
|
||||||
id -> Nullable<Integer>,
|
id -> Nullable<Integer>,
|
||||||
|
@ -9,10 +8,8 @@ mod schema {
|
||||||
completed -> Bool,
|
completed -> Bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
use schema::tasks;
|
use tasks::dsl::{tasks as all_tasks};
|
||||||
use schema::tasks::dsl::{tasks as all_tasks};
|
|
||||||
|
|
||||||
use crate::DbConn;
|
use crate::DbConn;
|
||||||
|
|
Loading…
Reference in a new issue