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

Method update_question

ch_10/src/store.rs:104–135  ·  view source on GitHub ↗
(
        self,
        question: Question,
        id: i32,
        account_id: AccountId,
    )

Source from the content-addressed store, hash-verified

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

Callers 1

update_questionFunction · 0.45

Calls 1

QuestionIdClass · 0.50

Tested by

no test coverage detected