Skip to content

Commit 12a029e

Browse files
committed
Fixes #88. Fixes #89.
Stable Version 0.10.0-beta.2.
1 parent acffdef commit 12a029e

File tree

15 files changed

+170
-61
lines changed

15 files changed

+170
-61
lines changed

Diff for: CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
##### 0.10.0-beta.2 - xx July 2014
1+
##### 0.10.0-beta.2 - 10 July 2014
2+
3+
###### Backwards compatible API changes
4+
- #89 - Added the `cacheResponse` option to `DS.create` and `DS.save`
25

36
###### Backwards compatible bug fixes
47
- #87 - Filter where boolean values
58

9+
###### Other
10+
- #88 - Fixed guide documentation for the simple default `where` filter
11+
612
##### 0.10.0-beta.1 - 28 June 2014
713

814
###### Breaking API changes

Diff for: Gruntfile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ module.exports = function (grunt) {
1111
require('load-grunt-tasks')(grunt);
1212
require('time-grunt')(grunt);
1313

14-
var dev = process.cwd().indexOf('/home/jdobry/angular-data') === -1,
15-
pkg = grunt.file.readJSON('package.json');
14+
var dev = process.cwd().indexOf('/home/jdobry/angular-data') === -1;
15+
var pkg = grunt.file.readJSON('package.json');
1616

1717
// Project configuration.
1818
grunt.initConfig({

Diff for: README.md

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

55
__Latest Release:__ [0.9.1](http://angular-data.pseudobry.com/)
6-
__master:__ [0.9.1](http://angular-data-next.pseudobry.com/)
6+
__master:__ [0.10.0-beta.2](http://angular-data-next.pseudobry.com/)
77

8-
Angular-data is in a pre-1.0.0 development stage; the API is fluctuating, not a lot of tests yet, etc.
8+
Angular-data is approaching 1.0.0 Beta. The API is stabilizing and angular-data is well tested.
99

10-
Not for production use (yet). If you still want to develop with Angular-data, be prepared to keep a close eye on the changelog, as the API is still liable to change before 1.0.0.
10+
Angular-data is being used in production, though it's not 1.0.0. If you want to use Angular-data, keep an eye on the changelog. 1.0.0 will introduce strict semver (minor number is bumped for breaking changes right now).
1111

1212
Roadmap:
13-
- Relations/Associations
14-
- Various Adapters
15-
- Schema Definition/Validation
13+
- Even more adapters
1614
- Nested Resources
17-
- See [issues](https://github.com/jmdobry/angular-data/issues?milestone=7&page=1&state=open) for what's in development
15+
- See [issues](https://github.com/jmdobry/angular-data/issues?page=1&state=open) for what's in development
1816
- See [Design Doc](https://docs.google.com/document/d/1o069KLuBH4jpwm1FCLZFwKMgM73Xi8_1JyjhSxVpidM/edit?usp=sharing) for other juicy reading material
1917

2018
## Changelog
2119
[CHANGELOG.md](https://github.com/jmdobry/angular-data/blob/master/CHANGELOG.md)
2220

21+
## Version Migration
22+
[TRANSITION.md](https://github.com/jmdobry/angular-data/blob/master/TRANSITION.md)
23+
2324
## Resources
2425

2526
#### Community

Diff for: dist/angular-data.js

+37-20
Original file line numberDiff line numberDiff line change
@@ -1854,7 +1854,10 @@ var errorPrefix = 'DS.create(resourceName, attrs[, options]): ';
18541854
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
18551855
* @param {object} attrs The attributes with which to update the item of the type specified by `resourceName` that has
18561856
* the primary key specified by `id`.
1857-
* @param {object=} options Configuration options.
1857+
* @param {object=} options Configuration options. Properties:
1858+
*
1859+
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
1860+
*
18581861
* @returns {Promise} Promise produced by the `$q` service.
18591862
*
18601863
* ## Resolves with:
@@ -1882,6 +1885,10 @@ function create(resourceName, attrs, options) {
18821885
var resource = this.store[resourceName];
18831886
var _this = this;
18841887

1888+
if (!('cacheResponse' in options)) {
1889+
options.cacheResponse = true;
1890+
}
1891+
18851892
promise = promise
18861893
.then(function (attrs) {
18871894
return _this.$q.promisify(definition.beforeValidate)(resourceName, attrs);
@@ -1902,11 +1909,15 @@ function create(resourceName, attrs, options) {
19021909
return _this.$q.promisify(definition.afterCreate)(resourceName, definition.deserialize(resourceName, res));
19031910
})
19041911
.then(function (data) {
1905-
var created = _this.inject(definition.name, data);
1906-
var id = created[definition.idAttribute];
1907-
resource.previousAttributes[id] = _this.utils.deepMixIn({}, created);
1908-
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]);
1909-
return _this.get(definition.name, id);
1912+
if (options.cacheResponse) {
1913+
var created = _this.inject(definition.name, data);
1914+
var id = created[definition.idAttribute];
1915+
resource.previousAttributes[id] = _this.utils.deepMixIn({}, created);
1916+
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]);
1917+
return _this.get(definition.name, id);
1918+
} else {
1919+
return data;
1920+
}
19101921
});
19111922

19121923
deferred.resolve(attrs);
@@ -2133,6 +2144,7 @@ var errorPrefix = 'DS.find(resourceName, id[, options]): ';
21332144
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
21342145
* @param {string|number} id The primary key of the item to retrieve.
21352146
* @param {object=} options Optional configuration. Properties:
2147+
*
21362148
* - `{boolean=}` - `bypassCache` - Bypass the cache. Default: `false`.
21372149
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
21382150
*
@@ -2166,8 +2178,6 @@ function find(resourceName, id, options) {
21662178

21672179
if (!('cacheResponse' in options)) {
21682180
options.cacheResponse = true;
2169-
} else {
2170-
options.cacheResponse = !!options.cacheResponse;
21712181
}
21722182

21732183
var definition = this.definitions[resourceName];
@@ -2316,6 +2326,7 @@ function _findAll(utils, resourceName, params, options) {
23162326
* - `{string|array=}` - `orderBy` - OrderBy clause.
23172327
*
23182328
* @param {object=} options Optional configuration. Properties:
2329+
*
23192330
* - `{boolean=}` - `bypassCache` - Bypass the cache. Default: `false`.
23202331
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
23212332
*
@@ -2351,8 +2362,6 @@ function findAll(resourceName, params, options) {
23512362

23522363
if (!('cacheResponse' in options)) {
23532364
options.cacheResponse = true;
2354-
} else {
2355-
options.cacheResponse = !!options.cacheResponse;
23562365
}
23572366

23582367
promise = promise.then(function () {
@@ -2645,7 +2654,7 @@ var errorPrefix = 'DS.refresh(resourceName, id[, options]): ';
26452654
*
26462655
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
26472656
* @param {string|number} id The primary key of the item to refresh from the server.
2648-
* @param {object=} options Optional configuration. Properties:
2657+
* @param {object=} options Optional configuration passed through to `DS.find` if it is called.
26492658
* @returns {false|Promise} `false` if the item doesn't already exist in the data store. A `Promise` if the item does
26502659
* exist in the data store and is being refreshed.
26512660
*
@@ -2712,7 +2721,9 @@ var errorPrefix = 'DS.save(resourceName, id[, options]): ';
27122721
*
27132722
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
27142723
* @param {string|number} id The primary key of the item to retrieve.
2715-
* @param {object=} options Optional configuration. Properties:
2724+
* @param {object=} options Optional configuration. Properties::
2725+
*
2726+
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
27162727
* - `{boolean=}` - `changesOnly` - Only send changed and added values back to the server.
27172728
*
27182729
* @returns {Promise} Promise produced by the `$q` service.
@@ -2753,6 +2764,10 @@ function save(resourceName, id, options) {
27532764
var resource = this.store[resourceName];
27542765
var _this = this;
27552766

2767+
if (!('cacheResponse' in options)) {
2768+
options.cacheResponse = true;
2769+
}
2770+
27562771
promise = promise
27572772
.then(function (attrs) {
27582773
return _this.$q.promisify(definition.beforeValidate)(resourceName, attrs);
@@ -2792,10 +2807,14 @@ function save(resourceName, id, options) {
27922807
return _this.$q.promisify(definition.afterUpdate)(resourceName, definition.deserialize(resourceName, res));
27932808
})
27942809
.then(function (data) {
2795-
_this.inject(definition.name, data, options);
2796-
resource.previousAttributes[id] = _this.utils.deepMixIn({}, data);
2797-
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]);
2798-
return _this.get(resourceName, id);
2810+
if (options.cacheResponse) {
2811+
var saved = _this.inject(definition.name, data, options);
2812+
resource.previousAttributes[id] = _this.utils.deepMixIn({}, saved);
2813+
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]);
2814+
return _this.get(resourceName, id);
2815+
} else {
2816+
return data;
2817+
}
27992818
});
28002819

28012820
deferred.resolve(item);
@@ -2842,6 +2861,7 @@ var errorPrefix = 'DS.update(resourceName, id, attrs[, options]): ';
28422861
* @param {string|number} id The primary key of the item to update.
28432862
* @param {object} attrs The attributes with which to update the item.
28442863
* @param {object=} options Optional configuration. Properties:
2864+
*
28452865
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
28462866
*
28472867
* @returns {Promise} Promise produced by the `$q` service.
@@ -2880,8 +2900,6 @@ function update(resourceName, id, attrs, options) {
28802900

28812901
if (!('cacheResponse' in options)) {
28822902
options.cacheResponse = true;
2883-
} else {
2884-
options.cacheResponse = !!options.cacheResponse;
28852903
}
28862904

28872905
promise = promise
@@ -2973,6 +2991,7 @@ var errorPrefix = 'DS.updateAll(resourceName, attrs, params[, options]): ';
29732991
* - `{string|array=}` - `orderBy` - OrderBy clause.
29742992
*
29752993
* @param {object=} options Optional configuration. Properties:
2994+
*
29762995
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
29772996
*
29782997
* @returns {Promise} Promise produced by the `$q` service.
@@ -3010,8 +3029,6 @@ function updateAll(resourceName, attrs, params, options) {
30103029

30113030
if (!('cacheResponse' in options)) {
30123031
options.cacheResponse = true;
3013-
} else {
3014-
options.cacheResponse = !!options.cacheResponse;
30153032
}
30163033

30173034
promise = promise

Diff for: dist/angular-data.min.js

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

Diff for: guide/angular-data/queries.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,9 @@ DS.filter('post', {
221221

222222
#### Shortcuts
223223

224-
These are equivalent:
224+
###### `==` operator shortcut
225+
226+
The following are equivalent:
225227
```js
226228
DS.filter('post', {
227229
author: 'John'
@@ -234,13 +236,15 @@ DS.filter('post', {
234236
DS.filter('post', {
235237
where: {
236238
author: {
237-
'in': ['John', 'Sally']
239+
'==': 'John'
238240
}
239241
}
240242
});
241243
```
242244

243-
These are equivalent:
245+
###### `orderBy` shortcut
246+
247+
The following are equivalent:
244248
```js
245249
DS.filter('post', {
246250
orderBy: 'age'

Diff for: src/datastore/async_methods/create.js

+17-6
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ var errorPrefix = 'DS.create(resourceName, attrs[, options]): ';
2929
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
3030
* @param {object} attrs The attributes with which to update the item of the type specified by `resourceName` that has
3131
* the primary key specified by `id`.
32-
* @param {object=} options Configuration options.
32+
* @param {object=} options Configuration options. Properties:
33+
*
34+
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
35+
*
3336
* @returns {Promise} Promise produced by the `$q` service.
3437
*
3538
* ## Resolves with:
@@ -57,6 +60,10 @@ function create(resourceName, attrs, options) {
5760
var resource = this.store[resourceName];
5861
var _this = this;
5962

63+
if (!('cacheResponse' in options)) {
64+
options.cacheResponse = true;
65+
}
66+
6067
promise = promise
6168
.then(function (attrs) {
6269
return _this.$q.promisify(definition.beforeValidate)(resourceName, attrs);
@@ -77,11 +84,15 @@ function create(resourceName, attrs, options) {
7784
return _this.$q.promisify(definition.afterCreate)(resourceName, definition.deserialize(resourceName, res));
7885
})
7986
.then(function (data) {
80-
var created = _this.inject(definition.name, data);
81-
var id = created[definition.idAttribute];
82-
resource.previousAttributes[id] = _this.utils.deepMixIn({}, created);
83-
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]);
84-
return _this.get(definition.name, id);
87+
if (options.cacheResponse) {
88+
var created = _this.inject(definition.name, data);
89+
var id = created[definition.idAttribute];
90+
resource.previousAttributes[id] = _this.utils.deepMixIn({}, created);
91+
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]);
92+
return _this.get(definition.name, id);
93+
} else {
94+
return data;
95+
}
8596
});
8697

8798
deferred.resolve(attrs);

Diff for: src/datastore/async_methods/find.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ var errorPrefix = 'DS.find(resourceName, id[, options]): ';
2929
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
3030
* @param {string|number} id The primary key of the item to retrieve.
3131
* @param {object=} options Optional configuration. Properties:
32+
*
3233
* - `{boolean=}` - `bypassCache` - Bypass the cache. Default: `false`.
3334
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
3435
*
@@ -62,8 +63,6 @@ function find(resourceName, id, options) {
6263

6364
if (!('cacheResponse' in options)) {
6465
options.cacheResponse = true;
65-
} else {
66-
options.cacheResponse = !!options.cacheResponse;
6766
}
6867

6968
var definition = this.definitions[resourceName];

Diff for: src/datastore/async_methods/findAll.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ function _findAll(utils, resourceName, params, options) {
103103
* - `{string|array=}` - `orderBy` - OrderBy clause.
104104
*
105105
* @param {object=} options Optional configuration. Properties:
106+
*
106107
* - `{boolean=}` - `bypassCache` - Bypass the cache. Default: `false`.
107108
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
108109
*
@@ -138,8 +139,6 @@ function findAll(resourceName, params, options) {
138139

139140
if (!('cacheResponse' in options)) {
140141
options.cacheResponse = true;
141-
} else {
142-
options.cacheResponse = !!options.cacheResponse;
143142
}
144143

145144
promise = promise.then(function () {

Diff for: src/datastore/async_methods/refresh.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var errorPrefix = 'DS.refresh(resourceName, id[, options]): ';
3535
*
3636
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
3737
* @param {string|number} id The primary key of the item to refresh from the server.
38-
* @param {object=} options Optional configuration. Properties:
38+
* @param {object=} options Optional configuration passed through to `DS.find` if it is called.
3939
* @returns {false|Promise} `false` if the item doesn't already exist in the data store. A `Promise` if the item does
4040
* exist in the data store and is being refreshed.
4141
*

Diff for: src/datastore/async_methods/save.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ var errorPrefix = 'DS.save(resourceName, id[, options]): ';
2727
*
2828
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
2929
* @param {string|number} id The primary key of the item to retrieve.
30-
* @param {object=} options Optional configuration. Properties:
30+
* @param {object=} options Optional configuration. Properties::
31+
*
32+
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
3133
* - `{boolean=}` - `changesOnly` - Only send changed and added values back to the server.
3234
*
3335
* @returns {Promise} Promise produced by the `$q` service.
@@ -68,6 +70,10 @@ function save(resourceName, id, options) {
6870
var resource = this.store[resourceName];
6971
var _this = this;
7072

73+
if (!('cacheResponse' in options)) {
74+
options.cacheResponse = true;
75+
}
76+
7177
promise = promise
7278
.then(function (attrs) {
7379
return _this.$q.promisify(definition.beforeValidate)(resourceName, attrs);
@@ -107,10 +113,14 @@ function save(resourceName, id, options) {
107113
return _this.$q.promisify(definition.afterUpdate)(resourceName, definition.deserialize(resourceName, res));
108114
})
109115
.then(function (data) {
110-
_this.inject(definition.name, data, options);
111-
resource.previousAttributes[id] = _this.utils.deepMixIn({}, data);
112-
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]);
113-
return _this.get(resourceName, id);
116+
if (options.cacheResponse) {
117+
var saved = _this.inject(definition.name, data, options);
118+
resource.previousAttributes[id] = _this.utils.deepMixIn({}, saved);
119+
resource.saved[id] = _this.utils.updateTimestamp(resource.saved[id]);
120+
return _this.get(resourceName, id);
121+
} else {
122+
return data;
123+
}
114124
});
115125

116126
deferred.resolve(item);

Diff for: src/datastore/async_methods/update.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ var errorPrefix = 'DS.update(resourceName, id, attrs[, options]): ';
3131
* @param {string|number} id The primary key of the item to update.
3232
* @param {object} attrs The attributes with which to update the item.
3333
* @param {object=} options Optional configuration. Properties:
34+
*
3435
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
3536
*
3637
* @returns {Promise} Promise produced by the `$q` service.
@@ -69,8 +70,6 @@ function update(resourceName, id, attrs, options) {
6970

7071
if (!('cacheResponse' in options)) {
7172
options.cacheResponse = true;
72-
} else {
73-
options.cacheResponse = !!options.cacheResponse;
7473
}
7574

7675
promise = promise

0 commit comments

Comments
 (0)