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