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

Method update_question

ch_07/src/store.rs:86–115  ·  view source on GitHub ↗
(
        &self,
        question: Question,
        question_id: i32,
    )

Source from the content-addressed store, hash-verified

84 }
85
86 pub async fn update_question(
87 &self,
88 question: Question,
89 question_id: i32,
90 ) -> Result<Question, Error> {
91 match sqlx::query(
92 "UPDATE questions SET title = $1, content = $2, tags = $3
93 WHERE id = $4
94 RETURNING id, title, content, tags",
95 )
96 .bind(question.title)
97 .bind(question.content)
98 .bind(question.tags)
99 .bind(question_id)
100 .map(|row: PgRow| Question {
101 id: QuestionId(row.get("id")),
102 title: row.get("title"),
103 content: row.get("content"),
104 tags: row.get("tags"),
105 })
106 .fetch_one(&self.connection)
107 .await
108 {
109 Ok(question) => Ok(question),
110 Err(e) => {
111 tracing::event!(tracing::Level::ERROR, "{:?}", e);
112 Err(Error::DatabaseQueryError)
113 }
114 }
115 }
116
117 pub async fn delete_question(
118 &self,

Callers 1

update_questionFunction · 0.45

Calls 1

QuestionIdClass · 0.50

Tested by

no test coverage detected