MCPcopy Index your code
hub / github.com/Rust-Web-Development/code / add_answer

Method add_answer

ch_11/src/store.rs:150–177  ·  view source on GitHub ↗
(self, answer: Answer, account_id: AccountId)

Source from the content-addressed store, hash-verified

148 }
149
150 pub async fn add_answer(self, answer: Answer, account_id: AccountId) -> Result<bool, Error> {
151 match sqlx::query(
152 "INSERT INTO answers (content, corresponding_question, account_id) VALUES ($1, $2, $3)",
153 )
154 .bind(answer.content)
155 .bind(answer.question_id)
156 .bind(account_id.0)
157 .execute(&self.connection)
158 .await
159 {
160 Ok(_) => Ok(true),
161 Err(error) => {
162 tracing::event!(
163 tracing::Level::ERROR,
164 code = error
165 .as_database_error()
166 .unwrap()
167 .code()
168 .unwrap()
169 .parse::<i32>()
170 .unwrap(),
171 db_message = error.as_database_error().unwrap().message(),
172 constraint = error.as_database_error().unwrap().constraint().unwrap()
173 );
174 Err(Error::DatabaseQueryError(error))
175 }
176 }
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)")

Callers 1

add_answerFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected