mz_deploy/client/
dev_overlays.rs1use crate::client::connection::DevOverlaysClient;
16use crate::client::errors::ConnectionError;
17
18impl DevOverlaysClient<'_> {
19 pub async fn list_overlays(
21 &self,
22 profile: &str,
23 project: &str,
24 ) -> Result<Vec<String>, ConnectionError> {
25 let rows = self
26 .client
27 .query(
28 "SELECT overlay_db FROM _mz_deploy.tables.dev_overlays \
29 WHERE profile = $1 AND project = $2 \
30 ORDER BY overlay_db",
31 &[&profile, &project],
32 )
33 .await?;
34 Ok(rows.into_iter().map(|r| r.get::<_, String>(0)).collect())
35 }
36
37 pub async fn insert_overlay(
39 &self,
40 profile: &str,
41 project: &str,
42 overlay_db: &str,
43 ) -> Result<(), ConnectionError> {
44 self.client
45 .execute(
46 "INSERT INTO _mz_deploy.tables.dev_overlays \
47 (profile, project, overlay_db, created_at) \
48 VALUES ($1, $2, $3, now())",
49 &[&profile, &project, &overlay_db],
50 )
51 .await?;
52 Ok(())
53 }
54
55 pub async fn delete_overlays(
57 &self,
58 profile: &str,
59 project: &str,
60 ) -> Result<(), ConnectionError> {
61 self.client
62 .execute(
63 "DELETE FROM _mz_deploy.tables.dev_overlays \
64 WHERE profile = $1 AND project = $2",
65 &[&profile, &project],
66 )
67 .await?;
68 Ok(())
69 }
70}