Skip to content

Commit 6fb58fc

Browse files
committed
Implement delete
1 parent 3388e24 commit 6fb58fc

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

postgres_resource_derive/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,10 @@ impl Parsed {
386386
.set(model)
387387
.get_result::<Self::ModelWithId>(&self.connection())?)
388388
}
389+
390+
fn delete(&self, by: Expr<#table>) -> Result<usize, Error> {
391+
Ok(delete(#table).filter(by).execute(&self.connection())?)
392+
}
389393
}
390394
}
391395
}

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,5 @@ where
5151
fn get_one(&self, by: Expr<Self::DBTable>) -> Result<Self::ModelWithId>;
5252
fn get_all(&self, by: Expr<Self::DBTable>) -> Result<Vec<Self::ModelWithId>>;
5353
fn update(&self, model: &Self::Model, by: Expr<Self::DBTable>) -> Result<Self::ModelWithId>;
54+
fn delete(&self, by: Expr<Self::DBTable>) -> Result<usize>;
5455
}

0 commit comments

Comments
 (0)