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

Method update_question

ch_11/src/store.rs:102–133  ·  view source on GitHub ↗
(
        self,
        question: Question,
        id: i32,
        account_id: AccountId,
    )

Source from the content-addressed store, hash-verified

100 }
101
102 pub async fn update_question(
103 self,
104 question: Question,
105 id: i32,
106 account_id: AccountId,
107 ) -> Result<Question, Error> {
108 match sqlx::query(
109 "UPDATE questions SET title = $1, content = $2, tags = $3
110 WHERE id = $4 AND account_id = $5
111 RETURNING id, title, content, tags",
112 )
113 .bind(question.title)
114 .bind(question.content)
115 .bind(question.tags)
116 .bind(id)
117 .bind(account_id.0)
118 .map(|row: PgRow| Question {
119 id: QuestionId(row.get("id")),
120 title: row.get("title"),
121 content: row.get("content"),
122 tags: row.get("tags"),
123 })
124 .fetch_one(&self.connection)
125 .await
126 {
127 Ok(question) => Ok(question),
128 Err(error) => {
129 tracing::event!(tracing::Level::ERROR, "{:?}", error);
130 Err(Error::DatabaseQueryError(error))
131 }
132 }
133 }
134
135 pub async fn delete_question(self, id: i32, account_id: AccountId) -> Result<bool, Error> {
136 match sqlx::query("DELETE FROM questions WHERE id = $1 AND account_id = $2")

Callers 1

update_questionFunction · 0.45

Calls 1

QuestionIdClass · 0.50

Tested by

no test coverage detected