ModelCollection
A ModelCollection is used to store multiple Models.
Inheritance: ModelCollection
> Array
> Object
Table of Contents #
create( [ values : Object ] ) : void #
Creates a new Model with the supplied values and adds it to the ModelCollection.
var collection = new ModelCollection(); collection.create( { name: "Mathias", age: 23 } );
append( model : Model [, prepend = false ] ) : void #
This method can be used to create the Model first and append it. By default it is appended as the last model. If prepend is true
the model is appended to the beginning.
It is preferred to use the append
method over native Array methods in order to include it in filtering procedures.
destroy( indicator : int | Model ) : Model #
Removes a Model from the collection and returns it. It is encouraged to use destroy over the use of splice
and other native Array methods to prevent tangling references.
var collection = new ModelCollection(); var modelA = new Model( { name: "Mathias" } ); var modelB = new Model( { name: "Joe" } ); collection.append( modelA ); collection.append( modelB ); var trash = collection.destroy( model A ); trash === modelA; // true collection.length; // 1 collection.destroy( 0 ) === modelB; // true;
Documentation generated by mdoc.