Skip to content

Commit bd96aa1

Browse files
authored
Merge pull request #36 from WyriHaximus/add-delete-to-repository
Add delete support to repository
2 parents e053108 + 0c8ec8d commit bd96aa1

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Repository.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ public function update(EntityInterface $entity): PromiseInterface
130130
});
131131
}
132132

133+
public function delete(EntityInterface $entity): PromiseInterface
134+
{
135+
return $this->client->query(
136+
$this->queryFactory->delete($this->entity->getTable())->
137+
where(field('id')->eq($entity->getId()))->asExpression()
138+
)->toPromise();
139+
}
140+
133141
private function buildSelectQuery(Where $constraints, Order $order): SelectQuery
134142
{
135143
$query = $this->buildBaseSelectQuery();

src/RepositoryInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ public function fetch(?Where $where = null, ?Order $order = null, int $limit = 0
2323
public function create(array $fields): PromiseInterface;
2424

2525
public function update(EntityInterface $entity): PromiseInterface;
26+
27+
public function delete(EntityInterface $entity): PromiseInterface;
2628
}

0 commit comments

Comments
 (0)