@@ -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 ) {
21772177function 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 ) ;
0 commit comments