@@ -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
0 commit comments