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

Method update_question

ch_09/src/store.rs:107–138  ·  view source on GitHub ↗
(
        self,
        question: Question,
        id: i32,
        account_id: AccountId,
    )

Source from the content-addressed store, hash-verified

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

Callers 1

update_questionFunction · 0.45

Calls 1

QuestionIdClass · 0.50

Tested by

no test coverage detected