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

Method add_question

ch_10/src/store.rs:78–102  ·  view source on GitHub ↗
(
        self,
        new_question: NewQuestion,
        account_id: AccountId,
    )

Source from the content-addressed store, hash-verified

76 }
77
78 pub async fn add_question(
79 self,
80 new_question: NewQuestion,
81 account_id: AccountId,
82 ) -> Result<Question, Error> {
83 match sqlx::query("INSERT INTO questions (title, content, tags, account_id) VALUES ($1, $2, $3, $4) RETURNING id, title, content, tags")
84 .bind(new_question.title)
85 .bind(new_question.content)
86 .bind(new_question.tags)
87 .bind(account_id.0)
88 .map(|row: PgRow| Question {
89 id: QuestionId(row.get("id")),
90 title: row.get("title"),
91 content: row.get("content"),
92 tags: row.get("tags"),
93 })
94 .fetch_one(&self.connection)
95 .await {
96 Ok(question) => Ok(question),
97 Err(error) => {
98 tracing::event!(tracing::Level::ERROR, "{:?}", error);
99 Err(Error::DatabaseQueryError(error))
100 },
101 }
102 }
103
104 pub async fn update_question(
105 self,

Callers 1

add_questionFunction · 0.45

Calls 1

QuestionIdClass · 0.50

Tested by

no test coverage detected