| 559 | } |
| 560 | |
| 561 | pub async fn list_policies( |
| 562 | &self, |
| 563 | sandbox_id: &str, |
| 564 | limit: u32, |
| 565 | offset: u32, |
| 566 | ) -> PersistenceResult<Vec<PolicyRecord>> { |
| 567 | let rows = sqlx::query( |
| 568 | r#" |
| 569 | SELECT "id", "scope", "version", "status", "payload", "created_at_ms" |
| 570 | FROM "objects" |
| 571 | WHERE "object_type" = ?1 AND "scope" = ?2 |
| 572 | ORDER BY "version" DESC, "created_at_ms" DESC |
| 573 | LIMIT ?3 OFFSET ?4 |
| 574 | "#, |
| 575 | ) |
| 576 | .bind(POLICY_OBJECT_TYPE) |
| 577 | .bind(sandbox_id) |
| 578 | .bind(i64::from(limit)) |
| 579 | .bind(i64::from(offset)) |
| 580 | .fetch_all(&self.pool) |
| 581 | .await |
| 582 | .map_err(|e| map_db_error(&e))?; |
| 583 | |
| 584 | rows.into_iter().map(row_to_policy_record).collect() |
| 585 | } |
| 586 | |
| 587 | pub async fn update_policy_status( |
| 588 | &self, |