Getting users via email in data access
If you have attempted to code this yourself, hopefully it will follow a similar approach. First with import the following:
// nanoservices/auth/dal/src/users/transactions/get.rs
use crate::users::schema::User;
use glue::errors::{NanoServiceError, NanoServiceErrorStatus};
use std::future::Future;
use super::super::descriptors::SqlxPostGresDescriptor;
use crate::connections::sqlx_postgres::SQLX_POSTGRES_POOL;
We then define our trait with the code below:
// nanoservices/auth/dal/src/users/transactions/get.rs
pub trait GetByEmail {
fn get_by_email(email: String)
-> impl Future<Output = Result<
User, NanoServiceError
>> + Send;
}
And implement this trait for our Postgres descriptor with the following code:
// nanoservices/auth/dal/src/users/transactions/get.rs
impl GetByEmail for SqlxPostGresDescriptor {
fn get_by_email(email: String)
-> impl Future<Output = Result<
User, NanoServiceError...