Plume/plume-models/src/apps.rs

33 lines
728 B
Rust
Raw Normal View History

use chrono::NaiveDateTime;
use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl};
use schema::apps;
use {Error, Result};
#[derive(Clone, Queryable, Serialize)]
pub struct App {
pub id: i32,
pub name: String,
pub client_id: String,
pub client_secret: String,
pub redirect_uri: Option<String>,
pub website: Option<String>,
pub creation_date: NaiveDateTime,
}
2018-10-21 18:22:27 +02:00
#[derive(Insertable)]
#[table_name = "apps"]
2018-10-21 18:22:27 +02:00
pub struct NewApp {
pub name: String,
pub client_id: String,
pub client_secret: String,
pub redirect_uri: Option<String>,
pub website: Option<String>,
2018-10-21 18:22:27 +02:00
}
impl App {
2018-10-21 18:22:27 +02:00
get!(apps);
insert!(apps, NewApp);
find_by!(apps, find_by_client_id, client_id as &str);
}