collection.where

wherecollection.where(attributes) Return an array of all the models in a collection that match the passed attributes. Useful for simple cases of filter. var friends = new Backbone.Collection([ {name: "Athos", job: "Musketeer"}, {name: "Porthos", job: "Musketeer"}, {name: "Aramis", job: "Musketeer"}, {name: "d'Artagnan", job: "Guard"}, ]); var musketeers = friends.where({job: "Musketeer"}); alert(musketeers.length);

collection.unshift

unshiftcollection.unshift(model, [options]) Add a model at the beginning of a collection. Takes the same options as add.

collection.url

urlcollection.url or collection.url() Set the url property (or function) on a collection to reference its location on the server. Models within the collection will use url to construct URLs of their own. var Notes = Backbone.Collection.extend({ url: '/notes' }); // Or, something more sophisticated: var Notes = Backbone.Collection.extend({ url: function() { return this.document.url() + '/notes'; } });

collection.toJSON

toJSONcollection.toJSON([options]) Return an array containing the attributes hash of each model (via toJSON) in the collection. This can be used to serialize and persist the collection as a whole. The name of this method is a bit confusing, because it conforms to JavaScript's JSON API. var collection = new Backbone.Collection([ {name: "Tim", age: 5}, {name: "Ida", age: 26}, {name: "Rob", age: 55} ]); alert(JSON.stringify(collection));

collection.toArray

toArray

collection.sortBy

sortBy

collection.sync

synccollection.sync(method, collection, [options]) Uses Backbone.sync to persist the state of a collection to the server. Can be overridden for custom behavior.

collection.some

some (any)

collection.shuffle

shuffle

collection.slice

slicecollection.slice(begin, end) Return a shallow copy of this collection's models, using the same options as native Array#slice.