<!DOCTYPE html>
<html>

  <head>
    <script src="https://cdn.firebase.com/js/client/2.1.2/firebase.js"></script>
    <script src="https://cdn.rawgit.com/js-data/js-data/master/dist/js-data.js"></script>
    <script src="https://cdn.rawgit.com/js-data/js-data-firebase/master/dist/js-data-firebase.js"></script>
    <script src="script.js"></script>
  </head>

  <body>
    <h1>Open up your console to see the output</h1>
  </body>

</html>
var store = new JSData.DS();
var fbAdapter = new DSFirebaseAdapter({
  basePath: 'https://js-data-firebase.firebaseio.com'
});
store.registerAdapter('fb', fbAdapter, { default: true });

var Document = store.defineResource('document');
var doc;

Document.create({
  author: 'John Anderson'
}).then(function (document) {
  doc = document;
  console.log('Document.get(doc.id)', Document.get(doc.id));
  
  console.log('Document.destroy(doc.id)');
  return Document.destroy(doc.id);
}).then(function () {
  console.log('Document.get(doc.id)', Document.get(doc.id));
});
## 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.

###### Arguments

| name | type | description |
| ---- | ---- | ----------- |
| resourceName | string | The name of the resource to use. Unnecessary if using the resource directly. |
| id | string or number | The primary key of the item to destroy. |
| options | object | Configuration options. Also passed through to the adapter and (conditionally) to `DS.eject`. |
| options.adapter | string | Override the default adapter. |
| options.beforeDestroy | function | Override the default beforeDestroy hook. |
| options.afterDestroy | function | Override the default afterDestroy hook. |
| options.eagerEject | function | Whether 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.notify | function | Whether to call the `beforeDestroy` and `afterDestroy` hooks and emit the `DS.beforeDestroy` and `DS.afterDestroy` events. Default: `true`. |

###### Examples

```js
Document.get(5); { id: 5, ... }

// See Method Variants section below for different ways to call DS#destroy
Document.destroy(5).then(function (id) {
  id; // 5
  
  // The document is gone
  Document.get(5); // undefined
});
```