diff options
| author | Jokler <jokler@protonmail.com> | 2020-06-21 06:37:46 +0200 |
|---|---|---|
| committer | Jokler <jokler@protonmail.com> | 2020-06-21 06:37:46 +0200 |
| commit | e6468b012d5b33dd16992652da57f11dd5a6e82f (patch) | |
| tree | e89add440df79d4036b9b44d8c77ee6d69e67201 /src/model.rs | |
| download | joklerpoints-master.tar.gz joklerpoints-master.zip | |
Diffstat (limited to 'src/model.rs')
| -rw-r--r-- | src/model.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/src/model.rs b/src/model.rs new file mode 100644 index 0000000..1d399da --- /dev/null +++ b/src/model.rs @@ -0,0 +1,54 @@ +use actix::{Actor, SyncContext}; +use chrono::NaiveDateTime; +use diesel::mysql::MysqlConnection; +use r2d2::Pool; +use r2d2_diesel::ConnectionManager; + +use crate::schema::{passwords, transactions, users}; + +pub struct DbExecutor(pub Pool<ConnectionManager<MysqlConnection>>); + +impl Actor for DbExecutor { + type Context = SyncContext<Self>; +} + +#[derive(Debug, Clone, Insertable)] +#[table_name = "transactions"] +pub struct NewTransaction<'a> { + pub sender: u64, + pub receiver: u64, + pub amount: u64, + pub sender_balance: u64, + pub receiver_balance: u64, + pub purpose: &'a str, +} + +#[derive(Debug, Clone, Queryable)] +pub struct User { + pub id: u64, + pub power_level: i32, + pub name: String, + pub created: NaiveDateTime, + pub balance: u64, +} + +#[derive(Debug, Clone, Insertable)] +#[table_name = "users"] +pub struct NewUser { + pub power_level: i32, + pub name: String, + pub balance: u64, +} + +#[derive(Debug, Clone, Queryable)] +pub struct Password { + pub id: u64, + pub hash: String, +} + +#[derive(Debug, Clone, Insertable)] +#[table_name = "passwords"] +pub struct NewPassword<'a> { + pub id: u64, + pub hash: &'a str, +} |
