Skip to content

Commit adc7ed3

Browse files
committed
Fixes #113. Closes #114.
1 parent 8e1b21d commit adc7ed3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+476
-317
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
##### 0.10.5 - 11 August 2014
2+
3+
###### Backwards compatible API changes
4+
- #114 - Include resourceName in error messages
5+
6+
###### Backwards compatible bug fixes
7+
- #113 - FindAll with object as a result
8+
19
##### 0.10.4 - 04 August 2014
210

311
###### Breaking API changes

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
__Data store for Angular.js.__
44

55
__Latest Release:__ [0.10.4](http://angular-data.pseudobry.com/)
6-
__master:__ [0.10.4](http://angular-data-next.pseudobry.com/)
6+
__master:__ [0.10.5](http://angular-data-next.pseudobry.com/)
77

88
Angular-data is approaching 1.0.0 Beta. The API is stabilizing and angular-data is well tested.
99

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "Jason Dobry",
33
"name": "angular-data",
44
"description": "Data store for Angular.js.",
5-
"version": "0.10.4",
5+
"version": "0.10.5",
66
"homepage": "http://angular-data.pseudobry.com/",
77
"repository": {
88
"type": "git",

dist/angular-data.js

+163-111
Large diffs are not rendered by default.

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.

guide/nav.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
<i class="icon-wrench icon-white"></i> API <b class="caret"></b>
7373
</a>
7474
<ul class="dropdown-menu">
75-
<li class="nav-header">Angular-data - 0.10.4</li>
75+
<li class="nav-header">Angular-data - 0.10.5</li>
7676
<li>
7777
<a href="/documentation/api/angular-data/angular-data">Overview</a>
7878
</li>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "angular-data",
33
"description": "Data store for Angular.js.",
4-
"version": "0.10.4",
4+
"version": "0.10.5",
55
"homepage": "http://angular-data.pseudobry.com",
66
"repository": {
77
"type": "git",

src/datastore/async_methods/create.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var errorPrefix = 'DS.create(resourceName, attrs[, options]): ';
1+
function errorPrefix(resourceName) {
2+
return 'DS.create(' + resourceName + ', attrs[, options]): ';
3+
}
24

35
/**
46
* @doc method
@@ -52,9 +54,9 @@ function create(resourceName, attrs, options) {
5254
options = options || {};
5355

5456
if (!this.definitions[resourceName]) {
55-
throw new this.errors.NER(errorPrefix + resourceName);
57+
throw new this.errors.NER(errorPrefix(resourceName) + resourceName);
5658
} else if (!this.utils.isObject(attrs)) {
57-
throw new this.errors.IA(errorPrefix + 'attrs: Must be an object!');
59+
throw new this.errors.IA(errorPrefix(resourceName) + 'attrs: Must be an object!');
5860
}
5961
var definition = this.definitions[resourceName];
6062
var resource = this.store[resourceName];

src/datastore/async_methods/destroy.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var errorPrefix = 'DS.destroy(resourceName, id): ';
1+
function errorPrefix(resourceName, id) {
2+
return 'DS.destroy(' + resourceName + ', ' + id + '): ';
3+
}
24

35
/**
46
* @doc method
@@ -50,14 +52,14 @@ function destroy(resourceName, id, options) {
5052
options = options || {};
5153

5254
if (!this.definitions[resourceName]) {
53-
throw new this.errors.NER(errorPrefix + resourceName);
55+
throw new this.errors.NER(errorPrefix(resourceName, id) + resourceName);
5456
} else if (!this.utils.isString(id) && !this.utils.isNumber(id)) {
55-
throw new this.errors.IA(errorPrefix + 'id: Must be a string or a number!');
57+
throw new this.errors.IA(errorPrefix(resourceName, id) + 'id: Must be a string or a number!');
5658
}
5759

5860
var item = this.get(resourceName, id);
5961
if (!item) {
60-
throw new this.errors.R(errorPrefix + 'id: "' + id + '" not found!');
62+
throw new this.errors.R(errorPrefix(resourceName, id) + 'id: "' + id + '" not found!');
6163
}
6264

6365
var definition = this.definitions[resourceName];

src/datastore/async_methods/destroyAll.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var errorPrefix = 'DS.destroyAll(resourceName, params[, options]): ';
1+
function errorPrefix(resourceName) {
2+
return 'DS.destroyAll(' + resourceName + ', params[, options]): ';
3+
}
24

35
/**
46
* @doc method
@@ -64,11 +66,11 @@ function destroyAll(resourceName, params, options) {
6466
options = options || {};
6567

6668
if (!this.definitions[resourceName]) {
67-
throw new this.errors.NER(errorPrefix + resourceName);
69+
throw new this.errors.NER(errorPrefix(resourceName) + resourceName);
6870
} else if (!this.utils.isObject(params)) {
69-
throw new IA(errorPrefix + 'params: Must be an object!');
71+
throw new IA(errorPrefix(resourceName) + 'params: Must be an object!');
7072
} else if (!this.utils.isObject(options)) {
71-
throw new IA(errorPrefix + 'options: Must be an object!');
73+
throw new IA(errorPrefix(resourceName) + 'options: Must be an object!');
7274
}
7375

7476
var definition = this.definitions[resourceName];

src/datastore/async_methods/find.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var errorPrefix = 'DS.find(resourceName, id[, options]): ';
1+
function errorPrefix(resourceName, id) {
2+
return 'DS.find(' + resourceName + ', ' + id + '[, options]): ';
3+
}
24

35
/**
46
* @doc method
@@ -54,11 +56,11 @@ function find(resourceName, id, options) {
5456
options = options || {};
5557

5658
if (!this.definitions[resourceName]) {
57-
throw new this.errors.NER(errorPrefix + resourceName);
59+
throw new this.errors.NER(errorPrefix(resourceName, id) + resourceName);
5860
} else if (!this.utils.isString(id) && !this.utils.isNumber(id)) {
59-
throw new IA(errorPrefix + 'id: Must be a string or a number!');
61+
throw new IA(errorPrefix(resourceName, id) + 'id: Must be a string or a number!');
6062
} else if (!this.utils.isObject(options)) {
61-
throw new IA(errorPrefix + 'options: Must be an object!');
63+
throw new IA(errorPrefix(resourceName, id) + 'options: Must be an object!');
6264
}
6365

6466
if (!('cacheResponse' in options)) {

src/datastore/async_methods/findAll.js

+28-19
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
var errorPrefix = 'DS.findAll(resourceName, params[, options]): ';
1+
function errorPrefix(resourceName) {
2+
return 'DS.findAll(' + resourceName + ', params[, options]): ';
3+
}
24

3-
function processResults(utils, data, resourceName, queryHash) {
4-
var resource = this.store[resourceName],
5-
idAttribute = this.definitions[resourceName].idAttribute,
6-
date = new Date().getTime();
5+
function processResults(data, resourceName, queryHash) {
6+
var resource = this.store[resourceName];
7+
var idAttribute = this.definitions[resourceName].idAttribute;
8+
var date = new Date().getTime();
79

810
data = data || [];
911

@@ -12,24 +14,31 @@ function processResults(utils, data, resourceName, queryHash) {
1214
resource.completedQueries[queryHash] = date;
1315

1416
// Update modified timestamp of collection
15-
resource.collectionModified = utils.updateTimestamp(resource.collectionModified);
17+
resource.collectionModified = this.utils.updateTimestamp(resource.collectionModified);
1618

1719
// Merge the new values into the cache
1820
var injected = this.inject(resourceName, data);
1921

2022
// Make sure each object is added to completedQueries
21-
angular.forEach(injected, function (item) {
22-
resource.completedQueries[item[idAttribute]] = date;
23-
});
23+
if (this.utils.isArray(injected)) {
24+
angular.forEach(injected, function (item) {
25+
if (item && item[idAttribute]) {
26+
resource.completedQueries[item[idAttribute]] = date;
27+
}
28+
});
29+
} else {
30+
this.$log.warn(errorPrefix(resourceName) + 'response is expected to be an array!');
31+
resource.completedQueries[injected[idAttribute]] = date;
32+
}
2433

2534
return injected;
2635
}
2736

28-
function _findAll(utils, resourceName, params, options) {
29-
var definition = this.definitions[resourceName],
30-
resource = this.store[resourceName],
31-
_this = this,
32-
queryHash = utils.toJson(params);
37+
function _findAll(resourceName, params, options) {
38+
var definition = this.definitions[resourceName];
39+
var resource = this.store[resourceName];
40+
var _this = this;
41+
var queryHash = _this.utils.toJson(params);
3342

3443
if (options.bypassCache || !options.cacheResponse) {
3544
delete resource.completedQueries[queryHash];
@@ -46,7 +55,7 @@ function _findAll(utils, resourceName, params, options) {
4655
var data = definition.deserialize(resourceName, res);
4756
if (options.cacheResponse) {
4857
try {
49-
return processResults.apply(_this, [utils, data, resourceName, queryHash]);
58+
return processResults.apply(_this, [data, resourceName, queryHash]);
5059
} catch (err) {
5160
return _this.$q.reject(err);
5261
}
@@ -139,19 +148,19 @@ function findAll(resourceName, params, options) {
139148
params = params || {};
140149

141150
if (!this.definitions[resourceName]) {
142-
throw new this.errors.NER(errorPrefix + resourceName);
151+
throw new this.errors.NER(errorPrefix(resourceName) + resourceName);
143152
} else if (!this.utils.isObject(params)) {
144-
throw new IA(errorPrefix + 'params: Must be an object!');
153+
throw new IA(errorPrefix(resourceName) + 'params: Must be an object!');
145154
} else if (!this.utils.isObject(options)) {
146-
throw new IA(errorPrefix + 'options: Must be an object!');
155+
throw new IA(errorPrefix(resourceName) + 'options: Must be an object!');
147156
}
148157

149158
if (!('cacheResponse' in options)) {
150159
options.cacheResponse = true;
151160
}
152161

153162
promise = promise.then(function () {
154-
return _findAll.apply(_this, [_this.utils, resourceName, params, options]);
163+
return _findAll.apply(_this, [resourceName, params, options]);
155164
});
156165
deferred.resolve();
157166
} catch (err) {

src/datastore/async_methods/loadRelations.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var errorPrefix = 'DS.loadRelations(resourceName, instance(Id), relations[, options]): ';
1+
function errorPrefix(resourceName) {
2+
return 'DS.loadRelations(' + resourceName + ', instance(Id), relations[, options]): ';
3+
}
24

35
/**
46
* @doc method
@@ -71,13 +73,13 @@ function loadRelations(resourceName, instance, relations, options) {
7173
}
7274

7375
if (!this.definitions[resourceName]) {
74-
throw new this.errors.NER(errorPrefix + resourceName);
76+
throw new this.errors.NER(errorPrefix(resourceName) + resourceName);
7577
} else if (!this.utils.isObject(instance)) {
76-
throw new IA(errorPrefix + 'instance(Id): Must be a string, number or object!');
78+
throw new IA(errorPrefix(resourceName) + 'instance(Id): Must be a string, number or object!');
7779
} else if (!this.utils.isArray(relations)) {
78-
throw new IA(errorPrefix + 'relations: Must be a string or an array!');
80+
throw new IA(errorPrefix(resourceName) + 'relations: Must be a string or an array!');
7981
} else if (!this.utils.isObject(options)) {
80-
throw new IA(errorPrefix + 'options: Must be an object!');
82+
throw new IA(errorPrefix(resourceName) + 'options: Must be an object!');
8183
}
8284

8385
var definition = this.definitions[resourceName];

src/datastore/async_methods/refresh.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var errorPrefix = 'DS.refresh(resourceName, id[, options]): ';
1+
function errorPrefix(resourceName, id) {
2+
return 'DS.refresh(' + resourceName + ', ' + id + '[, options]): ';
3+
}
24

35
/**
46
* @doc method
@@ -55,11 +57,11 @@ function refresh(resourceName, id, options) {
5557
options = options || {};
5658

5759
if (!this.definitions[resourceName]) {
58-
throw new this.errors.NER(errorPrefix + resourceName);
60+
throw new this.errors.NER(errorPrefix(resourceName, id) + resourceName);
5961
} else if (!this.utils.isString(id) && !this.utils.isNumber(id)) {
60-
throw new IA(errorPrefix + 'id: Must be a string or a number!');
62+
throw new IA(errorPrefix(resourceName, id) + 'id: Must be a string or a number!');
6163
} else if (!this.utils.isObject(options)) {
62-
throw new IA(errorPrefix + 'options: Must be an object!');
64+
throw new IA(errorPrefix(resourceName, id) + 'options: Must be an object!');
6365
} else {
6466
options.bypassCache = true;
6567

src/datastore/async_methods/save.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var errorPrefix = 'DS.save(resourceName, id[, options]): ';
1+
function errorPrefix(resourceName, id) {
2+
return 'DS.save(' + resourceName + ', ' + id + '[, options]): ';
3+
}
24

35
/**
46
* @doc method
@@ -54,16 +56,16 @@ function save(resourceName, id, options) {
5456
options = options || {};
5557

5658
if (!this.definitions[resourceName]) {
57-
throw new this.errors.NER(errorPrefix + resourceName);
59+
throw new this.errors.NER(errorPrefix(resourceName, id) + resourceName);
5860
} else if (!this.utils.isString(id) && !this.utils.isNumber(id)) {
59-
throw new IA(errorPrefix + 'id: Must be a string or a number!');
61+
throw new IA(errorPrefix(resourceName, id) + 'id: Must be a string or a number!');
6062
} else if (!this.utils.isObject(options)) {
61-
throw new IA(errorPrefix + 'options: Must be an object!');
63+
throw new IA(errorPrefix(resourceName, id) + 'options: Must be an object!');
6264
}
6365

6466
var item = this.get(resourceName, id);
6567
if (!item) {
66-
throw new this.errors.R(errorPrefix + 'id: "' + id + '" not found!');
68+
throw new this.errors.R(errorPrefix(resourceName, id) + 'id: "' + id + '" not found!');
6769
}
6870

6971
var definition = this.definitions[resourceName];

src/datastore/async_methods/update.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var errorPrefix = 'DS.update(resourceName, id, attrs[, options]): ';
1+
function errorPrefix(resourceName, id) {
2+
return 'DS.update(' + resourceName + ', ' + id + ', attrs[, options]): ';
3+
}
24

35
/**
46
* @doc method
@@ -55,13 +57,13 @@ function update(resourceName, id, attrs, options) {
5557
options = options || {};
5658

5759
if (!this.definitions[resourceName]) {
58-
throw new this.errors.NER(errorPrefix + resourceName);
60+
throw new this.errors.NER(errorPrefix(resourceName, id) + resourceName);
5961
} else if (!this.utils.isString(id) && !this.utils.isNumber(id)) {
60-
throw new IA(errorPrefix + 'id: Must be a string or a number!');
62+
throw new IA(errorPrefix(resourceName, id) + 'id: Must be a string or a number!');
6163
} else if (!this.utils.isObject(attrs)) {
62-
throw new IA(errorPrefix + 'attrs: Must be an object!');
64+
throw new IA(errorPrefix(resourceName, id) + 'attrs: Must be an object!');
6365
} else if (!this.utils.isObject(options)) {
64-
throw new IA(errorPrefix + 'options: Must be an object!');
66+
throw new IA(errorPrefix(resourceName, id) + 'options: Must be an object!');
6567
}
6668

6769
var definition = this.definitions[resourceName];

src/datastore/async_methods/updateAll.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var errorPrefix = 'DS.updateAll(resourceName, attrs, params[, options]): ';
1+
function errorPrefix(resourceName) {
2+
return 'DS.updateAll(' + resourceName + ', attrs, params[, options]): ';
3+
}
24

35
/**
46
* @doc method
@@ -69,13 +71,13 @@ function updateAll(resourceName, attrs, params, options) {
6971
options = options || {};
7072

7173
if (!this.definitions[resourceName]) {
72-
throw new this.errors.NER(errorPrefix + resourceName);
74+
throw new this.errors.NER(errorPrefix(resourceName) + resourceName);
7375
} else if (!this.utils.isObject(attrs)) {
74-
throw new IA(errorPrefix + 'attrs: Must be an object!');
76+
throw new IA(errorPrefix(resourceName) + 'attrs: Must be an object!');
7577
} else if (!this.utils.isObject(params)) {
76-
throw new IA(errorPrefix + 'params: Must be an object!');
78+
throw new IA(errorPrefix(resourceName) + 'params: Must be an object!');
7779
} else if (!this.utils.isObject(options)) {
78-
throw new IA(errorPrefix + 'options: Must be an object!');
80+
throw new IA(errorPrefix(resourceName) + 'options: Must be an object!');
7981
}
8082

8183
var definition = this.definitions[resourceName];

src/datastore/sync_methods/bindAll.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
var errorPrefix = 'DS.bindAll(scope, expr, resourceName, params[, cb]): ';
1+
function errorPrefix(resourceName) {
2+
return 'DS.bindAll(scope, expr, ' + resourceName + ', params[, cb]): ';
3+
}
24

35
/**
46
* @doc method
@@ -47,13 +49,13 @@ function bindOne(scope, expr, resourceName, params, cb) {
4749
var IA = this.errors.IA;
4850

4951
if (!this.utils.isObject(scope)) {
50-
throw new IA(errorPrefix + 'scope: Must be an object!');
52+
throw new IA(errorPrefix(resourceName) + 'scope: Must be an object!');
5153
} else if (!this.utils.isString(expr)) {
52-
throw new IA(errorPrefix + 'expr: Must be a string!');
54+
throw new IA(errorPrefix(resourceName) + 'expr: Must be a string!');
5355
} else if (!this.definitions[resourceName]) {
54-
throw new this.errors.NER(errorPrefix + resourceName);
56+
throw new this.errors.NER(errorPrefix(resourceName) + resourceName);
5557
} else if (!this.utils.isObject(params)) {
56-
throw new IA(errorPrefix + 'params: Must be an object!');
58+
throw new IA(errorPrefix(resourceName) + 'params: Must be an object!');
5759
}
5860

5961
var _this = this;

0 commit comments

Comments
 (0)