Update an existing model in LocalStorage * @param {Model} model - The model to update * @returns {Model} The updated model
(model)
| 79 | * @returns {Model} The updated model |
| 80 | */ |
| 81 | update(model) { |
| 82 | this._setItem(this._itemName(model.id), this.serializer.serialize(model)); |
| 83 | |
| 84 | const modelId = model.id.toString(); |
| 85 | |
| 86 | if (!contains(this.records, modelId)) { |
| 87 | this.records.push(modelId); |
| 88 | this.save(); |
| 89 | } |
| 90 | return this.find(model); |
| 91 | } |
| 92 | |
| 93 | /** Retrieve a model from local storage by model id |
| 94 | * @param {Model} model - The Backbone Model to lookup |