| 319 | } |
| 320 | |
| 321 | pub async fn get_by_name( |
| 322 | &self, |
| 323 | object_type: &str, |
| 324 | name: &str, |
| 325 | ) -> PersistenceResult<Option<ObjectRecord>> { |
| 326 | let row = sqlx::query( |
| 327 | r#" |
| 328 | SELECT "object_type", "id", "name", "payload", "created_at_ms", "updated_at_ms", "labels", "resource_version" |
| 329 | FROM "objects" |
| 330 | WHERE "object_type" = ?1 AND "name" = ?2 |
| 331 | "#, |
| 332 | ) |
| 333 | .bind(object_type) |
| 334 | .bind(name) |
| 335 | .fetch_optional(&self.pool) |
| 336 | .await |
| 337 | .map_err(|e| map_db_error(&e))?; |
| 338 | |
| 339 | Ok(row.map(row_to_object_record)) |
| 340 | } |
| 341 | |
| 342 | pub async fn delete(&self, object_type: &str, id: &str) -> PersistenceResult<bool> { |
| 343 | let result = sqlx::query( |