MCPcopy Create free account
hub / github.com/actix/examples / get_users

Function get_users

databases/postgres/src/db.rs:6–19  ·  view source on GitHub ↗
(client: &Client)

Source from the content-addressed store, hash-verified

4use crate::{errors::MyError, models::User};
5
6pub async fn get_users(client: &Client) -> Result<Vec<User>, MyError> {
7 let stmt = include_str!("../sql/get_users.sql");
8 let stmt = stmt.replace("$table_fields", &User::sql_table_fields());
9 let stmt = client.prepare(&stmt).await.unwrap();
10
11 let results = client
12 .query(&stmt, &[])
13 .await?
14 .iter()
15 .map(|row| User::from_row_ref(row).unwrap())
16 .collect::<Vec<User>>();
17
18 Ok(results)
19}
20
21pub async fn add_user(client: &Client, user_info: User) -> Result<User, MyError> {
22 let _stmt = include_str!("../sql/add_user.sql");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected