DS#destroy(resourceName, id[, options])

The "D" in "CRUD". Delegate to the destroy method of whichever adapter is being used and eject the appropriate item from the data store.

Returns a promise of the deleted resource's id.

resourceNamestringThe name of the resource to use. Unnecessary if using the resource directly.
idstring or numberThe primary key of the item to destroy.
optionsobjectConfiguration options. Also passed through to the adapter and (conditionally) to DS.eject.
options.paramsobjectAdditional parameters for request.
options.adapterstringOverride the default adapter.
options.beforeDestroyfunctionOverride the default beforeDestroy hook.
options.afterDestroyfunctionOverride the default afterDestroy hook.
options.eagerEjectfunctionWhether to eject the item from the data store without waiting for a response from the adapter. If an error is thrown the item will be re-injected into the store. Default: false.
options.notifyfunctionWhether to call the beforeDestroy and afterDestroy hooks and emit the DS.beforeDestroy and DS.afterDestroy events. Default: true.
Live Demo


Method Variants

You can call DS#destroy multiple ways:

  • DS#destroy(resourceName, id)
  • Resource#destroy(id) - Where Resource was created by DS#defineResource
  • Instance#DSDestroy() - Where instance is an instance of a Resource


Need help?

Want more examples or have a question? Ask on the Slack channel or post on the mailing list then we'll get your question answered and probably update this wiki.