#[macro_export]
macro_rules! psql_read {
    ( $Self:ty, $pool:ident, $id:ident, $table_name:expr ) => {{
        let result = sqlx::query_as!(
            $Self,
            "SELECT * FROM " + $table_name + " WHERE id = $1",
            $id
        )
        .fetch_one($pool)
        .await?;

        Ok(Box::new(result))
    }};
}

#[macro_export]
macro_rules! psql_read_all {
    ( $Self:ty, $pool:ident, $table_name:expr ) => {{
        let mut results = sqlx::query_as!($Self, "SELECT * FROM " + $table_name + ";").fetch($pool);

        let mut output = Vec::<Box<$Self>>::new();

        while let Some(result) = results.try_next().await? {
            output.push(Box::new(result));
        }

        Ok(output)
    }};
}

#[macro_export]
macro_rules! psql_delete {
    ( $id:ident, $pool:ident, $table_name:expr ) => {{
        let _result = sqlx::query!("DELETE FROM " + $table_name + " WHERE id = $1", $id)
            .execute($pool)
            .await?;

        Ok(())
    }};
}
