MCPcopy Create free account
hub / github.com/Rust-Web-Development/code / add_account

Method add_account

ch_09/src/store.rs:199–233  ·  view source on GitHub ↗
(
        self,
        account: Account,
    )

Source from the content-addressed store, hash-verified

197 }
198
199 pub async fn add_account(
200 self,
201 account: Account,
202 ) -> Result<bool, Error> {
203 match sqlx::query(
204 "INSERT INTO accounts (email, password) VALUES ($1, $2)",
205 )
206 .bind(account.email)
207 .bind(account.password)
208 .execute(&self.connection)
209 .await
210 {
211 Ok(_) => Ok(true),
212 Err(error) => {
213 tracing::event!(
214 tracing::Level::ERROR,
215 code = error
216 .as_database_error()
217 .unwrap()
218 .code()
219 .unwrap()
220 .parse::<i32>()
221 .unwrap(),
222 db_message =
223 error.as_database_error().unwrap().message(),
224 constraint = error
225 .as_database_error()
226 .unwrap()
227 .constraint()
228 .unwrap()
229 );
230 Err(Error::DatabaseQueryError(error))
231 }
232 }
233 }
234
235 pub async fn get_account(
236 self,

Callers 1

registerFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected