GeneIT/geneit_backend/src/services/users_service.rs

23 lines
582 B
Rust
Raw Normal View History

2023-05-24 14:19:46 +00:00
//! # Users service
use crate::db_connection;
use crate::models::{NewUser, User};
use crate::schema::users;
use crate::utils::time_utils::time;
use diesel::prelude::*;
/// Create a new account
pub async fn create_account(name: &str, email: &str) -> anyhow::Result<User> {
db_connection::execute(|conn| {
let res = diesel::insert_into(users::table)
.values(&NewUser {
name: name.trim(),
email: email.trim(),
time_create: time() as i64,
})
.get_result(conn)?;
Ok(res)
})
}