An observable array-like object constructor.
Returns an array-like object with a number of methods for managing a collection.
var collection = Collection();
.remove()
Removes all objects from the collection.
.remove(id)
Removes object found via collection.find(id)
from the collection.
.remove(object)
Removes object found via collection.find(object)
from the collection.
.find(id)
returns the object in the collection with that id, or undefined
.
.find(object)
returns object
if it is already in the collection. Otherwise if object
has an id
, that is used to .find(id)
an object.
Filters the collection by the properties of queryObject
.sort()
sorts the collection by object.id
by default. Override the default by defining options.sort
as a function.
.sort(fn)
sorts the collection by the return value of fn
, like array.sort(fn)
.
Creates a new collection that is bound to the current one, but filtered by queryObject
.
If they all have the same value, returns value of property name
of the objects in the collection. Otherwise returns undefined
.
Sets property name
of all objects in the collection to value
.
Also, a Collection inherits the Array methods:
.map()
.reduce()
.concat()
.slice()
.some()
.indexOf()
.forEach()