Skip to content

Commit ad29d65

Browse files
committed
Fixed the update method of DSLocalStorage adapter.
1 parent 43354da commit ad29d65

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

dist/angular-data.js

+8-4
Original file line numberDiff line numberDiff line change
@@ -2580,7 +2580,11 @@ function DSLocalStorageAdapterProvider() {
25802580
*/
25812581
update: function (resourceConfig, id, attrs, options) {
25822582
options = options || {};
2583-
return this.PUT(DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(id, options), id), attrs);
2583+
var _this = this;
2584+
return _this.find(resourceConfig, id, options).then(function (item) {
2585+
DSUtils.deepMixIn(item, attrs);
2586+
return _this.PUT(DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(id, options), id), item);
2587+
});
25842588
},
25852589

25862590
/**
@@ -3977,7 +3981,7 @@ function errorPrefix(resourceName) {
39773981
*
39783982
* DS.filter('document', params); // []
39793983
*
3980-
* DS.updateAll('document', 5, {
3984+
* DS.updateAll('document', {
39813985
* author: 'Sally'
39823986
* }, params).then(function (documents) {
39833987
* documents; // The documents that were updated via an adapter
@@ -4081,8 +4085,6 @@ module.exports = updateAll;
40814085
},{}],67:[function(require,module,exports){
40824086
var observe = require('../../lib/observe-js/observe-js');
40834087

4084-
var total = 0;
4085-
40864088
function lifecycleNoop(resourceName, attrs, cb) {
40874089
cb(null, attrs);
40884090
}
@@ -4105,6 +4107,8 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
41054107
sort: ''
41064108
};
41074109

4110+
params = params || {};
4111+
41084112
if (_this.utils.isObject(params.where)) {
41094113
where = params.where;
41104114
} else {

dist/angular-data.min.js

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/adapters/localStorage.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,11 @@ function DSLocalStorageAdapterProvider() {
284284
*/
285285
update: function (resourceConfig, id, attrs, options) {
286286
options = options || {};
287-
return this.PUT(DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(id, options), id), attrs);
287+
var _this = this;
288+
return _this.find(resourceConfig, id, options).then(function (item) {
289+
DSUtils.deepMixIn(item, attrs);
290+
return _this.PUT(DSUtils.makePath(options.baseUrl || resourceConfig.baseUrl, resourceConfig.getEndpoint(id, options), id), item);
291+
});
288292
},
289293

290294
/**

src/datastore/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
var observe = require('../../lib/observe-js/observe-js');
22

3-
var total = 0;
4-
53
function lifecycleNoop(resourceName, attrs, cb) {
64
cb(null, attrs);
75
}
@@ -24,6 +22,8 @@ Defaults.prototype.defaultFilter = function (collection, resourceName, params, o
2422
sort: ''
2523
};
2624

25+
params = params || {};
26+
2727
if (_this.utils.isObject(params.where)) {
2828
where = params.where;
2929
} else {

0 commit comments

Comments
 (0)