LastModel extends ExistModel
Contract for models able to fetch their most recent document.
A LastModel extends ExistModel and adds a LastModel::last()
operation returning the "latest" document. By default an implementation sorts
on the modified property, so last() yields the most recently changed
document, but the ordering can be overridden through the options.
Tags
Table of Contents
Methods
- exist() : bool
- Indicates whether a document matching the given options exists.
- last() : mixed
- Returns the last document in the model.
Methods
exist()
Indicates whether a document matching the given options exists.
public
exist([array<string|int, mixed> $init = [] ]) : bool
Parameters
- $init : array<string|int, mixed> = []
-
Operation options identifying the document to test, typically a
key/idvalue, a set ofconditionsand theirbinds.
Tags
Return values
bool —true if at least one matching document exists, otherwise false.
last()
Returns the last document in the model.
public
last([array<string|int, mixed> $init = [] ]) : mixed
Parameters
- $init : array<string|int, mixed> = []
-
Operation options driving the lookup, typically the
sortfield used to determine "last" (default: themodifiedproperty), optionalconditionsandbinds.
Tags
Return values
mixed —The last matching document, or a null/empty value when the collection is empty, depending on the implementation.