lib/stores/sql/destroy.js
function(options) {
    const Store = require('../../store')

    var self = this
    var primaryKeys = this.definition.primaryKeys
    var condition = {}

    options = options || {}

    for (var i = 0; i < primaryKeys.length; i++) {
      condition[primaryKeys[i]] = this[primaryKeys[i]]
    }

    return self.store.startTransaction(options, function() {
      return self
        .callInterceptors('beforeDestroy', [self, options])
        .then(function() {
          var query = self.definition.query(options)

          return query
            .where(condition)
            .delete()
            .catch(function(error) {
              debug(query.toString())
              throw new Store.SQLError(error)
            })
            .then(function() {
              debug(query.toString())
            })
            .then(function() {
              return self.callInterceptors('afterDestroy', [self, options])
            })
            .then(function() {
              self.__exists = false
              return self
            })
        })
    })
  }
function(options) {
    const Store = require('../../store')

    var self = this
    var primaryKeys = this.definition.primaryKeys
    var condition = {}

    options = options || {}

    for (var i = 0; i < primaryKeys.length; i++) {
      condition[primaryKeys[i]] = this[primaryKeys[i]]
    }

    return self.store.startTransaction(options, function() {
      return self
        .callInterceptors('beforeDestroy', [self, options])
        .then(function() {
          var query = self.definition.query(options)

          return query
            .where(condition)
            .delete()
            .catch(function(error) {
              debug(query.toString())
              throw new Store.SQLError(error)
            })
            .then(function() {
              debug(query.toString())
            })
            .then(function() {
              return self.callInterceptors('afterDestroy', [self, options])
            })
            .then(function() {
              self.__exists = false
              return self
            })
        })
    })
  }
function ( options ) { const Store = require ( '../../store' ) var self = this var primaryKeys = this . definition . primaryKeys var condition = { } options = options || { } for ( var i = 0 ; i < primaryKeys . length ; i ++ ) { condition [ primaryKeys [ i ] ] = this [ primaryKeys [ i ] ] } return self . store . startTransaction ( options , function ( ) { return self . callInterceptors ( 'beforeDestroy' , [ self , options ] ) . then ( function ( ) { var query = self . definition . query ( options ) return query . where ( condition ) . delete ( ) . catch ( function ( error ) { debug ( query . toString ( ) ) throw new Store . SQLError ( error ) } ) . then ( function ( ) { debug ( query . toString ( ) ) } ) . then ( function ( ) { return self . callInterceptors ( 'afterDestroy' , [ self , options ] ) } ) . then ( function ( ) { self . __exists = false return self } ) } ) } ) }
Destroy a record

@class Record
@method destroy


@return {Record}
Destroy a record