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

Method add_account

ch_10/src/store.rs:196–230  ·  view source on GitHub ↗
(
        self,
        account: Account,
    )

Source from the content-addressed store, hash-verified

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

Callers 1

registerFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected