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

Method add_account

ch_11/src/store.rs:179–203  ·  view source on GitHub ↗
(self, account: Account)

Source from the content-addressed store, hash-verified

177 }
178
179 pub async fn add_account(self, account: Account) -> Result<bool, Error> {
180 match sqlx::query("INSERT INTO accounts (email, password) VALUES ($1, $2)")
181 .bind(account.email)
182 .bind(account.password)
183 .execute(&self.connection)
184 .await
185 {
186 Ok(_) => Ok(true),
187 Err(error) => {
188 tracing::event!(
189 tracing::Level::ERROR,
190 code = error
191 .as_database_error()
192 .unwrap()
193 .code()
194 .unwrap()
195 .parse::<i32>()
196 .unwrap(),
197 db_message = error.as_database_error().unwrap().message(),
198 constraint = error.as_database_error().unwrap().constraint().unwrap()
199 );
200 Err(Error::DatabaseQueryError(error))
201 }
202 }
203 }
204
205 pub async fn get_account(self, email: String) -> Result<Account, Error> {
206 match sqlx::query("SELECT * from accounts where email = $1")

Callers 1

registerFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected