Skip to content

Commit 192a9da

Browse files
committed
Api doc updates.
1 parent 519d33b commit 192a9da

File tree

5 files changed

+28
-36
lines changed

5 files changed

+28
-36
lines changed

dist/angular-data.js

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ function errorPrefix(resourceName) {
20872087
*
20882088
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
20892089
* @param {object} attrs The attributes with which to create the item of the type specified by `resourceName`.
2090-
* @param {object=} options Configuration options. Passed directly to the adapter's `create` method. Properties:
2090+
* @param {object=} options Configuration options. Also passed along to the adapter's `create` method. Properties:
20912091
*
20922092
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
20932093
* - `{boolean=}` - `upsert` - If `attrs` already contains a primary key, then attempt to call `DS.update` instead. Default: `true`.
@@ -2175,39 +2175,36 @@ module.exports = create;
21752175

21762176
},{}],39:[function(require,module,exports){
21772177
function errorPrefix(resourceName, id) {
2178-
return 'DS.destroy(' + resourceName + ', ' + id + '): ';
2178+
return 'DS.destroy(' + resourceName + ', ' + id + '[, options]): ';
21792179
}
21802180

21812181
/**
21822182
* @doc method
21832183
* @id DS.async_methods:destroy
21842184
* @name destroy
21852185
* @description
2186-
* Delete the item of the type specified by `resourceName` with the primary key specified by `id` from the data store
2187-
* and the server.
2186+
* The "D" in "CRUD". Delegate to the `destroy` method of whatever adapter is being used (http by default) eject the
2187+
* appropriate item from the data store.
21882188
*
21892189
* ## Signature:
21902190
* ```js
2191-
* DS.destroy(resourceName, id);
2191+
* DS.destroy(resourceName, id[, options]);
21922192
* ```
21932193
*
21942194
* ## Example:
21952195
*
21962196
* ```js
2197-
* DS.destroy('document', 'aab7ff66-e21e-46e2-8be8-264d82aee535')
2198-
* .then(function (id) {
2199-
* id; // 'aab7ff66-e21e-46e2-8be8-264d82aee535'
2197+
* DS.destroy('document', 5).then(function (id) {
2198+
* id; // 5
22002199
*
2201-
* // The document is gone
2202-
* DS.get('document', 'aab7ff66-e21e-46e2-8be8-264d82aee535'); // undefined
2203-
* }, function (err) {
2204-
* // Handle error
2205-
* });
2200+
* // The document is gone
2201+
* DS.get('document', 5); // undefined
2202+
* });
22062203
* ```
22072204
*
22082205
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
22092206
* @param {string|number} id The primary key of the item to remove.
2210-
* @param {object=} options Configuration options.
2207+
* @param {object=} options Configuration options. Also passed along to the adapter's `destroy` method.
22112208
* @returns {Promise} Promise produced by the `$q` service.
22122209
*
22132210
* ## Resolves with:
@@ -2224,11 +2221,12 @@ function destroy(resourceName, id, options) {
22242221
var DS = this;
22252222
var deferred = DS.$q.defer();
22262223
var promise = deferred.promise;
2224+
var definition = DS.definitions[resourceName];
22272225

22282226
try {
22292227
options = options || {};
22302228

2231-
if (!DS.definitions[resourceName]) {
2229+
if (!definition) {
22322230
throw new DS.errors.NER(errorPrefix(resourceName, id) + resourceName);
22332231
} else if (!DS.utils.isString(id) && !DS.utils.isNumber(id)) {
22342232
throw new DS.errors.IA(errorPrefix(resourceName, id) + 'id: Must be a string or a number!');
@@ -2239,8 +2237,6 @@ function destroy(resourceName, id, options) {
22392237
throw new DS.errors.R(errorPrefix(resourceName, id) + 'id: "' + id + '" not found!');
22402238
}
22412239

2242-
var definition = DS.definitions[resourceName];
2243-
22442240
promise = promise
22452241
.then(function (attrs) {
22462242
return DS.$q.promisify(definition.beforeDestroy)(resourceName, attrs);

dist/angular-data.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/datastore/async_methods/create.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function errorPrefix(resourceName) {
3030
*
3131
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
3232
* @param {object} attrs The attributes with which to create the item of the type specified by `resourceName`.
33-
* @param {object=} options Configuration options. Passed directly to the adapter's `create` method. Properties:
33+
* @param {object=} options Configuration options. Also passed along to the adapter's `create` method. Properties:
3434
*
3535
* - `{boolean=}` - `cacheResponse` - Inject the data returned by the server into the data store. Default: `true`.
3636
* - `{boolean=}` - `upsert` - If `attrs` already contains a primary key, then attempt to call `DS.update` instead. Default: `true`.

src/datastore/async_methods/destroy.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
function errorPrefix(resourceName, id) {
2-
return 'DS.destroy(' + resourceName + ', ' + id + '): ';
2+
return 'DS.destroy(' + resourceName + ', ' + id + '[, options]): ';
33
}
44

55
/**
66
* @doc method
77
* @id DS.async_methods:destroy
88
* @name destroy
99
* @description
10-
* Delete the item of the type specified by `resourceName` with the primary key specified by `id` from the data store
11-
* and the server.
10+
* The "D" in "CRUD". Delegate to the `destroy` method of whatever adapter is being used (http by default) eject the
11+
* appropriate item from the data store.
1212
*
1313
* ## Signature:
1414
* ```js
15-
* DS.destroy(resourceName, id);
15+
* DS.destroy(resourceName, id[, options]);
1616
* ```
1717
*
1818
* ## Example:
1919
*
2020
* ```js
21-
* DS.destroy('document', 'aab7ff66-e21e-46e2-8be8-264d82aee535')
22-
* .then(function (id) {
23-
* id; // 'aab7ff66-e21e-46e2-8be8-264d82aee535'
21+
* DS.destroy('document', 5).then(function (id) {
22+
* id; // 5
2423
*
25-
* // The document is gone
26-
* DS.get('document', 'aab7ff66-e21e-46e2-8be8-264d82aee535'); // undefined
27-
* }, function (err) {
28-
* // Handle error
29-
* });
24+
* // The document is gone
25+
* DS.get('document', 5); // undefined
26+
* });
3027
* ```
3128
*
3229
* @param {string} resourceName The resource type, e.g. 'user', 'comment', etc.
3330
* @param {string|number} id The primary key of the item to remove.
34-
* @param {object=} options Configuration options.
31+
* @param {object=} options Configuration options. Also passed along to the adapter's `destroy` method.
3532
* @returns {Promise} Promise produced by the `$q` service.
3633
*
3734
* ## Resolves with:
@@ -48,11 +45,12 @@ function destroy(resourceName, id, options) {
4845
var DS = this;
4946
var deferred = DS.$q.defer();
5047
var promise = deferred.promise;
48+
var definition = DS.definitions[resourceName];
5149

5250
try {
5351
options = options || {};
5452

55-
if (!DS.definitions[resourceName]) {
53+
if (!definition) {
5654
throw new DS.errors.NER(errorPrefix(resourceName, id) + resourceName);
5755
} else if (!DS.utils.isString(id) && !DS.utils.isNumber(id)) {
5856
throw new DS.errors.IA(errorPrefix(resourceName, id) + 'id: Must be a string or a number!');
@@ -63,8 +61,6 @@ function destroy(resourceName, id, options) {
6361
throw new DS.errors.R(errorPrefix(resourceName, id) + 'id: "' + id + '" not found!');
6462
}
6563

66-
var definition = DS.definitions[resourceName];
67-
6864
promise = promise
6965
.then(function (attrs) {
7066
return DS.$q.promisify(definition.beforeDestroy)(resourceName, attrs);

test/integration/datastore/async_methods/destroy.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
describe('DS.destroy(resourceName, id)', function () {
22
function errorPrefix(resourceName, id) {
3-
return 'DS.destroy(' + resourceName + ', ' + id + '): ';
3+
return 'DS.destroy(' + resourceName + ', ' + id + '[, options]): ';
44
}
55

66
beforeEach(startInjector);

0 commit comments

Comments
 (0)