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

Method get_questions

ch_09/src/store.rs:35–58  ·  view source on GitHub ↗
(
        self,
        limit: Option<i32>,
        offset: i32,
    )

Source from the content-addressed store, hash-verified

33 }
34
35 pub async fn get_questions(
36 self,
37 limit: Option<i32>,
38 offset: i32,
39 ) -> Result<Vec<Question>, Error> {
40 match sqlx::query("SELECT * from questions LIMIT $1 OFFSET $2")
41 .bind(limit)
42 .bind(offset)
43 .map(|row: PgRow| Question {
44 id: QuestionId(row.get("id")),
45 title: row.get("title"),
46 content: row.get("content"),
47 tags: row.get("tags"),
48 })
49 .fetch_all(&self.connection)
50 .await
51 {
52 Ok(questions) => Ok(questions),
53 Err(e) => {
54 tracing::event!(tracing::Level::ERROR, "{:?}", e);
55 Err(Error::DatabaseQueryError(e))
56 }
57 }
58 }
59
60 pub async fn is_question_owner(
61 &self,

Callers 1

get_questionsFunction · 0.45

Calls 1

QuestionIdClass · 0.50

Tested by

no test coverage detected