constructor no longer has the option to initialize with a collection of records, use add()
This commit is contained in:
parent
cccffd3fa4
commit
d44346d7be
|
@ -22,18 +22,23 @@
|
||||||
* // create a new record (in-memory)
|
* // create a new record (in-memory)
|
||||||
* let pets = new Record();
|
* let pets = new Record();
|
||||||
*
|
*
|
||||||
|
* @example
|
||||||
|
* // create a new record (localStorage)
|
||||||
|
* let pets = new Record({"store": "pets"});
|
||||||
|
*
|
||||||
* @param {array} init - collection to start with
|
* @param {array} init - collection to start with
|
||||||
* @param {object} opts
|
* @param {object} opts
|
||||||
* @param {object} opts.store - localStorage ID to use
|
* @param {object} opts.store - localStorage ID to use
|
||||||
* @param {object} opts.debug - show console logs
|
* @param {object} opts.debug - show console logs
|
||||||
*/
|
*/
|
||||||
constructor(init, opts) {
|
constructor(opts) {
|
||||||
// define options
|
// define options
|
||||||
this.store = (opts || {}).store;
|
this.store = (opts || {}).store;
|
||||||
this.debug = (opts || {}).debug || false;
|
this.debug = (opts || {}).debug || false;
|
||||||
|
|
||||||
// initialize the collection
|
// initialize the collection
|
||||||
this.records = Array.isArray(init) ? init : [];
|
this.records = [];
|
||||||
|
|
||||||
// get stored records, merge as needed
|
// get stored records, merge as needed
|
||||||
if(this.store && localStorage) {
|
if(this.store && localStorage) {
|
||||||
this._log("Initializing localStorage for " + this.store);
|
this._log("Initializing localStorage for " + this.store);
|
||||||
|
|
Loading…
Reference in New Issue