           (status,response,isSuccess)=>
             if isSuccess
               @_setStatus 'deleted'
+              @destroy()
               success?()
             else
               @_setStatus 'error'

        return
    inst

  Resource::query = (params,success,error)->
    inst = new @Collection @
    http
      method: 'GET'
      url: @genUrl params, false

      @_setStatus 'saving'
      return

  CollectionInstance = (ModelType)->
    constructor: (@_res)->
      Collection.call @
      @_status = 'loading'
      return

    Model: ModelType
    _setStatus: setStatus
    status: getStatus

    requery: (params)->
      @_res.query params, undefined, undefined, @
      @

    _toM: (o)->
      o =
        if o instanceof @Model then o
        else new @Model @_res, o, false
      o._setParent @
      o

  Resource