add
Add an object
Returns: Collection
of Model
objects
as
Set model for collection
asOptions
Return an array ref containing [{ value => $value, label => $label }, ...]
avg
Return the average value for given $field
collect
Instantiate a new collection
count
Return the size of objects
each
Map through each object and call the callback
exclude
Exclude objects that doesn't match criteria
Returns: Collection
of Model
objects
filter
Filter objects by callback
Returns: Collection
of Model
objects
find
Find object by primary key, of if args is a hash ref then find first object matching given args
Returns: Model
object
findOrNew
Find object or create a new instance
Returns: Model
object
first
Get first object
Returns: Model
object
firstOrNew
Get first object if exists, otherwise create one
Returns: Model
object
get
Get object by index
Returns: Collection
of Model
objects
indexOf
Get the index of an object
last
Get last object
Returns: Model
object
lists
Return an array ref containing all the fields from all objects for the given $field. Return a hash ref containing $key_field => $value_field if both are given.
max
Return the maximum value for given $field
min
Return the minimum value for given $field
newObject
Instantiate new object
Returns: Model
object
next
Get next object
Returns: Model
object
only
Return an array ref containing only given @keys
orderBy
Order collection
page
Take a collection containing only the results from a given page
Returns: Collection
of Model
objects
remove
Remove an object
reset
Reset index
search
Search objects by given args
Returns: Collection
of Model
objects
slice
Take a slice from the collection
Returns: Collection
of Model
objects
splice
Splice objects
sum
Sum by $field
toArray
Convert collection to array ref
toCsv
Convert collection to CSV string
toJson
Convert collection to JSON string
touch
Touch collections model
unique
Return an array ref containing only unique values for given $field
where
Search objects where field is equal to value
Returns: Collection
of Model
objects
whereIn
Search objects where field is in $array
Returns: Collection
of Model
objects
whereNotIn
Search objects where field is not in $array
Returns: Collection
of Model
objects
__first
Find first object that match $callback
Returns: Model
object
__list
Return a scalar, or an array if the value is a collection