1
0
Fork 0
This commit is contained in:
Florian RICHER 2021-07-08 17:13:35 +02:00
parent ee2bfbb769
commit 653267344f
3 changed files with 10 additions and 12 deletions

View file

@ -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
View file

@ -0,0 +1 @@
pub mod task;

View file

@ -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;