(
self,
limit: Option<i32>,
offset: i32,
)
| 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, |
no test coverage detected