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_migrations;
|
||||
|
||||
mod models;
|
||||
|
||||
use rocket::*;
|
||||
use rocket::fairing::AdHoc;
|
||||
use rocket_sync_db_pools::{database};
|
||||
|
||||
mod task;
|
||||
|
||||
#[database("sqlite_logs")]
|
||||
pub struct DbConn(diesel::SqliteConnection);
|
||||
|
||||
|
@ -17,7 +17,7 @@ fn index() -> &'static str {
|
|||
|
||||
#[get("/log/<id>")]
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
1
src/models/mod.rs
Normal file
1
src/models/mod.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub mod task;
|
|
@ -1,18 +1,15 @@
|
|||
use rocket::serde::Serialize;
|
||||
use diesel::{self, result::QueryResult, Queryable, Insertable, prelude::*};
|
||||
|
||||
mod schema {
|
||||
table! {
|
||||
tasks {
|
||||
id -> Nullable<Integer>,
|
||||
description -> Text,
|
||||
completed -> Bool,
|
||||
}
|
||||
table! {
|
||||
tasks {
|
||||
id -> Nullable<Integer>,
|
||||
description -> Text,
|
||||
completed -> Bool,
|
||||
}
|
||||
}
|
||||
|
||||
use schema::tasks;
|
||||
use schema::tasks::dsl::{tasks as all_tasks};
|
||||
use tasks::dsl::{tasks as all_tasks};
|
||||
|
||||
use crate::DbConn;
|
||||
|
Loading…
Reference in a new issue