- WIP on entity save

This commit is contained in:
Dave Mc Nicoll committed 2020-01-31 16:38:48 -05:00
1 parent 5bd60129ea
commit d12623cc5e
5 files changed
+33 -220

No files matched your search

+17 -7
View File
@@ -26,21 +26,21 @@ class Repository
$this->entityResolver = Ulmus::resolveEntity($entity);
}
public function loadOne() : EntityCollection
public function loadOne() : ? object
{
return $this->limit(1)->collectionFromQuery();
return $this->limit(1)->collectionFromQuery()[0] ?? null;
}
public function loadFromPk($value, $primaryKey = "id") : ? object
{
return $this->where($primaryKey, $value)->loadOne();
}
public function loadAll() : EntityCollection
{
return $this->collectionFromQuery();
}
public function loadFromPk($value, $primaryKey = "id") : EntityCollection
{
return $this->where($primaryKey, $value)->loadOne();
}
public function loadFromField($field, $value) : EntityCollection
{
return $this->where($field, $value)->collectionFromQuery();
@@ -61,6 +61,16 @@ class Repository
return $this->where($primaryKey, $value)->deleteOne();
}
public function save(object $entity) : bool
{
}
public function saveAll(EntityCollection $collection) : bool
{
}
public function yieldAll() : \Generator
{