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

Method add_question

ch_11/src/store.rs:76–100  ·  view source on GitHub ↗
(
        self,
        new_question: NewQuestion,
        account_id: AccountId,
    )

Source from the content-addressed store, hash-verified

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

Callers 1

add_questionFunction · 0.45

Calls 1

QuestionIdClass · 0.50

Tested by

no test coverage detected