EntityRepo<T>
Basic interface for entity services.
Instance Methods
| Returns | Signature and Description |
|---|---|
int | countAll()Counts several records by some arbitrary criteria. |
Traversable<T> | findAll(, , )Finds several records by some arbitrary criteria. |
?T | findById()Gets a single document by ID. |
?T | findOne()Finds a single record by some arbitrary criteria. |
T | get()Gets a single document by ID, throwing an exception if it's not found. |
Traversable<T> | getAll()Gets several documents by ID. |
ImmMap<string,T> | getInstanceMap()Gets a Map that relates identifier to instance |
string | getType()Gets the type of entity produced, mainly for ACL reasons. |
Method Details
countAll
countAll(ConstMap<string,mixed> $criteria)Counts several records by some arbitrary criteria.
- Since
- 0.6.0
| Name | Type | Description |
|---|---|---|
$criteria | ConstMap<string,mixed> | Field to value pairs |
| Type | Description |
|---|---|
int | The count of the documents |
| Type | Conditions |
|---|---|
Unreachable | If the connection fails |
Unretrievable | If the result cannot be returned |
Generic | If any other database problem occurs |
findAll
findAll(ConstMap<string,mixed> $criteria, ?Pagination $pagination = null, ?bool $totalCount = false)Finds several records by some arbitrary criteria.
| Name | Type | Description |
|---|---|---|
$criteria | ConstMap<string,mixed> | Field to value pairs |
$pagination | ?Pagination | Optional pagination parameters |
$totalCount | ?bool | Return a |
| Type | Description |
|---|---|
Traversable<T> | The objects found or null if none |
| Type | Conditions |
|---|---|
Unreachable | If the connection fails |
Unretrievable | If the result cannot be returned |
Generic | If any other database problem occurs |
findById
findById(mixed $id)Gets a single document by ID.
| Name | Type | Description |
|---|---|---|
$id | mixed | The document identifier |
| Type | Description |
|---|---|
?T | The entity |
| Type | Conditions |
|---|---|
Unreachable | If the connection fails |
Unretrievable | If the result cannot be returned |
Generic | If any other database problem occurs |
findOne
findOne(ConstMap<string,mixed> $criteria)Finds a single record by some arbitrary criteria.
| Name | Type | Description |
|---|---|---|
$criteria | ConstMap<string,mixed> | Field to value pairs |
| Type | Description |
|---|---|
?T | The object found or null if none |
| Type | Conditions |
|---|---|
Unreachable | If the connection fails |
Unretrievable | If the result cannot be returned |
Generic | If any other database problem occurs |
get
get(mixed $id)Gets a single document by ID, throwing an exception if it's not found.
| Name | Type | Description |
|---|---|---|
$id | mixed | The document identifier |
| Type | Description |
|---|---|
T | The entity |
| Type | Conditions |
|---|---|
Unreachable | If the connection fails |
Unretrievable | If the document doesn't exist |
Generic | If any other database problem occurs |
getAll
getAll(ConstVector<mixed> $ids)Gets several documents by ID.
| Name | Type | Description |
|---|---|---|
$ids | ConstVector<mixed> | Array of identifiers |
| Type | Description |
|---|---|
Traversable<T> | The results |
| Type | Conditions |
|---|---|
Unreachable | If the connection fails |
Unretrievable | If the result cannot be returned |
Generic | If any other database problem occurs |
getInstanceMap
getInstanceMap(Traversable<T> $entities)Gets a Map that relates identifier to instance
| Name | Type | Description |
|---|---|---|
$entities | Traversable<T> | The entities to "zip" |
| Type | Description |
|---|---|
ImmMap<string,T> | The instances keyed by identifier |
getType
getType()Gets the type of entity produced, mainly for ACL reasons.
| Type | Description |
|---|---|
string | The entity type |