| 269 | return this._noItemFound( {ret, ...params } ); |
| 270 | } |
| 271 | remove(params) { |
| 272 | return this._mapPromise.then(() => { |
| 273 | let m = this._m; |
| 274 | let { key, id } = params; |
| 275 | |
| 276 | if(id === undefined) { |
| 277 | if(this.enableCache && this.cache[key]) { |
| 278 | delete this.cache[key]; |
| 279 | } |
| 280 | return this.removeItem(key); |
| 281 | } |
| 282 | let newId = this._getId(key, id); |
| 283 | |
| 284 | //remove existed data |
| 285 | if(m[newId] !== undefined) { |
| 286 | if(this.enableCache && this.cache[newId]) { |
| 287 | delete this.cache[newId]; |
| 288 | } |
| 289 | this._removeIdInKey(key, id); |
| 290 | let idTobeDeleted = m[newId]; |
| 291 | delete m[newId]; |
| 292 | this.setItem('map', JSON.stringify(m)); |
| 293 | return this.removeItem('map_' + idTobeDeleted); |
| 294 | } |
| 295 | }); |
| 296 | } |
| 297 | _removeIdInKey(key, id) { |
| 298 | let indexTobeRemoved = (this._m.__keys__[key] || []).indexOf(id); |
| 299 | if (indexTobeRemoved !== -1) { |