Deletes a Backbone.DynamoDB.Model from a DynamoDB table using a DeleteItem request.

@param {Backbone.DynamoDB.Model} model The model to delete from DynamoDB.
@param {Object} options The options object.
172478
function deleteItem(model, options) {
	var request,
		deferred = new _.Deferred(),
		params = {
			Key: key.call( model ),
			TableName: model._tableName()
		};

	options || ( options = {} );
	wrapComplete( model, options );
	_.extend( params, options.dynamodb );

	if ( options.serializeDates !== false ) {
		// If the hash and/or range attributes are `Date` instance they must be serialized before sending the request.
		serializeAllDates( model, params.Key );
	}

	request = dynamo().deleteItem( params );

	request.on('complete', function (response) {
		var ctx = options.context || model;

		if ( response.error ) {
			deferred.rejectWith( ctx, [ response, options ] );
		} else {
			deferred.resolveWith( ctx, [ response, options ] );
		}
	});
	request.send();

	deferred.done( options.success ).fail( options.error ).always( options.complete );

	return deferred.promise( request );
}
1002432
function(model, options) {
            var index, existing;

            if (_.isArray(model)) {
                return _.map(model, function(m) {
                    return this.add(m, _.clone(options));
                }, this);
            }

            // Manage {list:[], n:0} for infinite list
            if (_.size(model) == 2
            && model.list != null && model.n != null) {
                this._totalCount = model.n;
                return this.add(model.list, options);
            }

            options = _.defaults({}, options || {}, {
                at: this.models.length,
                merge: false,
                silent: false
            });

            model = this._prepareModel(model);

            if (existing = this.get(model)) {
                if (options.merge) {
                    existing.set(model.toJSON())
                }
                return this;
            }

            this._byId[model.id] = model;

            this.listenTo(model, 'all', this._onModelEvent);
            this.listenTo(model, 'id', this._onModelId);

            index = options.at;
            this.models.splice(index, 0, model);

            if (options.silent) return this;
            options.index = index;
            this.trigger('add', model, this, options);

            if (this.comparator) this.sort({silent: options.silent});
            return model;
        }
1076971
function(server, model, options, logger) {
      // This line must come first
      validationHelper.validateModel(model, logger)
      const Log = logger.bind(chalk.yellow('DeleteOne'))

      let collectionName = model.collectionDisplayName || model.modelName
      if (config.logRoutes) {
        Log.note('Generating Delete One endpoint for ' + collectionName)
      }

      options = options || {}

      let resourceAliasForRoute

      if (model.routeOptions) {
        resourceAliasForRoute = model.routeOptions.alias || model.modelName
      } else {
        resourceAliasForRoute = model.modelName
      }

      let handler = HandlerHelper.generateDeleteHandler(model, options, Log)

      let payloadModel = null
      if (config.enableSoftDelete) {
        payloadModel = Joi.object({ hardDelete: Joi.bool() }).allow(null)

        if (!config.enablePayloadValidation) {
          payloadModel = Joi.alternatives().try(payloadModel, Joi.any())
        }
      }

      let auth = false
      let deleteOneHeadersValidation = Object.assign(headersValidation, {})

      if (config.authStrategy && model.routeOptions.deleteAuth !== false) {
        auth = {
          strategy: config.authStrategy
        }

        let scope = authHelper.generateScopeForEndpoint(model, 'delete', Log)

        if (!_.isEmpty(scope)) {
          auth.scope = scope
          if (config.logScopes) {
            Log.debug(
              'Scope for DELETE/' + resourceAliasForRoute + '/{_id}' + ':',
              scope
            )
          }
        }
      } else {
        deleteOneHeadersValidation = null
      }

      let policies = []

      if (model.routeOptions.policies && config.enablePolicies) {
        policies = model.routeOptions.policies
        policies = (policies.rootPolicies || []).concat(
          policies.deletePolicies || []
        )
      }

      if (config.enableDocumentScopes && auth) {
        policies.push(restHapiPolicies.enforceDocumentScopePre(model, Log))
        policies.push(restHapiPolicies.enforceDocumentScopePost(model, Log))
      }

      if (config.enableDeletedBy && config.enableSoftDelete) {
        policies.push(restHapiPolicies.addDeletedBy(model, Log))
      }

      if (config.enableAuditLog) {
        policies.push(restHapiPolicies.logDelete(mongoose, model, Log))
      }

      server.route({
        method: 'DELETE',
        path: '/' + resourceAliasForRoute + '/{_id}',
        config: {
          handler: handler,
          auth: auth,
          cors: config.cors,
          description: 'Delete a ' + collectionName,
          tags: ['api', collectionName],
          validate: {
            params: {
              _id: Joi.objectId().required()
            },
            payload: payloadModel,
            headers: deleteOneHeadersValidation
          },
          plugins: {
            model: model,
            'hapi-swagger': {
              responseMessages: [
                {
                  code: 200,
                  message: 'The resource was deleted successfully.'
                },
                { code: 400, message: 'The request was malformed.' },
                {
                  code: 401,
                  message:
                    'The authentication header was missing/malformed, or the token has expired.'
                },
                {
                  code: 404,
                  message: 'There was no resource found with that ID.'
                },
                { code: 500, message: 'There was an unknown error.' },
                {
                  code: 503,
                  message: 'There was a problem with the database.'
                }
              ]
            },
            policies: policies
          },
          response: {
            // TODO: add a response schema if needed
            // failAction: config.enableResponseFail ? 'error' : 'log',
            // schema: model.readModel ? model.readModel : Joi.object().unknown().optional()
          }
        }
      })
    }
323429
function(ev, model, collection, options) {
      if ((ev == 'add' || ev == 'remove') && collection != this) return;
      if (ev == 'destroy') {
        this._remove(model, options);
      }
      if (model && ev === 'change:' + model.idAttribute) {
        delete this._byId[model.previous(model.idAttribute)];
        this._byId[model.id] = model;
      }
      this.trigger.apply(this, arguments);
    }
892365
function sync(method, instance, options) {
	if ( method === 'delete' ) {
		return deleteItem( instance, options );
	} else if ( method === 'create' || method === 'update' ) {
		return putItem( instance, options );
	} // `method` equals 'read' below this point

	if ( instance instanceof Backbone.DynamoDB.Collection ) {
		return fetchCollection( instance, options );
	}

	return getItem( instance, options );
}
21650
function(options) {
    var self = this

    options = options || {}

    return self
      .callInterceptors('beforeDestroy', [self, options])
      .then(function() {
        return new Promise(function(resolve, reject) {
          self.model.definition.store.connection.del(
            self.dn,
            options.controls || [],
            function(err) {
              if (err)
                return reject(
                  self.definition.store.convertLdapErrorToValidationError(
                    self,
                    err
                  )
                )

              resolve(self.callInterceptors('afterDestroy', [self, options]))
            }
          )
        })
      })
      .then(function(record) {
        record.__exists = false
        return record
      })
  }
334280
function(view, options) {
        options = _.extend({}, options);
        var model = options.model || view.model,
            collection = options.collection || view.collection;

        if(model) {
          unbindModel(model, view);
        }
        else if(collection) {
          collection.each(function(model){
            unbindModel(model, view);
          });
          collection.unbind('add', collectionAdd);
          collection.unbind('remove', collectionRemove);
        }
      }
1257981
protected boolean deleteModel(MODEL_ID id, boolean permanent) throws Exception {
        if (permanent) {
            server.deletePermanent(modelType, id);
        } else {
            server.delete(modelType, id);
        }
        return permanent;
    }
937100
function(changedModel, options) {

        // Don't update unless the model is different
        var newModel = model.syncMonitor.get('model');
        if (_.isEqual(JSON.parse(JSON.stringify(model)), JSON.parse(JSON.stringify(newModel)))) {
          log.info('monitorListener.noChanges', t.className, newModel);
          return;
        }

        // Disconnect if the model was deleted or the ID isn't the same
        var isDeleted = (_.size(newModel) === 0);
        if (isDeleted || newModel.id !== modelId)  {
          log.info('modelListener.deleted', t.className, newModel);
          disconnectListeners();
        }

        // Forward changes to the model (including server-side delete)
        var newOpts = {isSyncChanging:true};
        if (isDeleted) {
          log.info('modelListener.deleting', t.className, newModel);
          model.clear(newOpts);
        } else {
          // Make sure the model is set to exactly the new contents (vs. override)
          log.info('modelListener.setting', t.className, newModel);
          model.clear({silent:true});
          model.set(newModel, newOpts);
        }
      }
1284169
function putItem(model, options) {
	options || ( options = {} );
	if ( options.serializeDates !== false ) {
		// If serializeDates is NOT `false`, use `true` by default.
		options.serializeDates = true;
	}

	var newKey, // If the model `isNew`, a new key is generated.
		request,
		hashName, // Name of the hash attribute.
		rangeName, // Name of the range attribute.
		keyPromise,
		deferred = new _.Deferred(),
		/**
		 * Container object to store the attributes that are changed as part of saving the model.
		 */
		changed = {},
		/**
		 * Parameters to use in the DynamoDB PutItem request
		 */
		params = {
			/**
			 * Convert the model into an object.
			 * If `options.serializeDates` is `true`, `Date` values are converted into strings.
			 */
			Item: model.toJSON( options ),
			TableName: model._tableName()
		};

	if ( model.isNew() ) { // If the model is new, a new key attribute(s) must be generated
		hashName = _.result( model, 'hashAttribute' ) || _.result( model, 'idAttribute' );
		rangeName = _.result( model, 'rangeAttribute' );

		/**
		 * Convenience method to set the `newKey` attribute(s), once it's generated.
		 */
		function setNewKey(_newKey) {
			if ( rangeName ) {
				/**
				 * If the model has a range attribute, _newKey must be an object that contains
				 * the hash and range attributes.
				 */
				_.extend( changed, _newKey );
			} else {
				/**
				 * If the model doesn't have a range attribute, _newKey must be the value of the hash attribute.
				 */
				changed[ hashName ] = _newKey;
			}

			// Add the new key attribute(s) to the Item to be sent to DynamoDB
			_.extend( params.Item, options.serializeDates === true ? serializeAllDates( model, _.clone( changed ) ) : changed );
		}

		// Generate new key attribute(s)
		newKey = model.newKey( options );

		if ( isPromise( newKey ) ) {
			/**
			 * If `newKey` is a promise, wait until it's resolved to execute `setNewKey`
			 * and assign the resulting promise to `keyPromise`.
			 */
			keyPromise = newKey.then( setNewKey );
		} else {
			// If `newKey` is NOT a promise, call `setNewKey` right away.
			setNewKey( newKey );
		}
	}

	wrapComplete( model, options );
	_.extend( params, options.dynamodb );

	request = dynamo().putItem( params );

	request.on('complete', function (response) {
		var ctx = options.context || model;

		if ( response.error ) {
			deferred.rejectWith( ctx, [ response, options ] );
		} else {
			/**
			 * Backbone's "internal" success callback takes the changed attributes as the first argument.
			 * Make the entire AWS `response` available as `options.awsResponse`.
			 */
			options.awsResponse = response;
			deferred.resolveWith( ctx, [ changed, options ] );
		}
	});

	if ( !keyPromise ) {
		// If there's no `keyPromise`, send the request right away.
		request.send();
	} else {
		// If there's a `keyPromise`, wait until it is "done" before sending the request.
		keyPromise.done(function () {
			request.send();
		}).fail(function () {
			var ctx = options.context || model;
			deferred.rejectWith( ctx, arguments );
		});
	}

	deferred.done( options.success ).fail( options.error ).always( options.complete );

	return deferred.promise( request );
}
1188609
function(view, options) {
        options = _.extend({}, defaultOptions, defaultCallbacks, options);

        var model = options.model || view.model,
            collection = options.collection || view.collection;

        if(typeof model === 'undefined' && typeof collection === 'undefined'){
          throw 'Before you execute the binding your view must have a model or a collection.\n' +
                'See http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.';
        }

        if(model) {
          bindModel(view, model, options);
        }
        else if(collection) {
          collection.each(function(model){
            bindModel(view, model, options);
          });
          collection.bind('add', collectionAdd, {view: view, options: options});
          collection.bind('remove', collectionRemove);
        }
      }
1038950
def delete(self, model):
        

        signals.pre_delete.send(model.__class__, model=model)

        param = {'rid_value': self.to_pg(model)[model.rid_field]}
        query = """
                DELETE FROM {table}
                WHERE {rid_field} = %(rid_value)s
                RETURNING {cols};
                """

        query = query.format(
            cols=self.field_cols(model),
            rid_field=model.rid_field,
            table=model.rtype,
        )

        result = self.query(query, param=param)

        signals.post_delete.send(model.__class__, model=model)

        return result
1036068
function(models, options) {
      var i, l, index, model;
      options || (options = {});
      models = _.isArray(models) ? models.slice() : [models];
      for (i = 0, l = models.length; i < l; i++) {
        model = this.getByCid(models[i]) || this.get(models[i]);
        if (!model) continue;
        delete this._byId[model.id];
        delete this._byCid[model.cid];
        index = this.indexOf(model);
        this.models.splice(index, 1);
        this.length--;
        if (!options.silent) {
          options.index = index;
          model.trigger('remove', model, this, options);
        }
        this._removeReference(model);
      }
      return this;
    }
490235
function (model, options) {
        this._index(model);
        if (!model.collection) model.collection = this;
        if (model.on) model.on('all', this._onModelEvent, this);
    }
132519
def delete(options = {:hard => false})
      if options[:hard]
        self.class.delete(self.id, options)
      else
        return if new_record? or destroyed?
        update_column kakurenbo_column, current_time_from_proper_timezone
      end
    end
2194
function(model, options) {
      options || (options = {});
      model = this._prepareModel(model, options);
      if (!model) return false;
      var already = this.getByCid(model) || this.get(model);
      if (already) throw new Error(["Can't add the same model to a set twice", already.id]);
      this._byId[model.id] = model;
      this._byCid[model.cid] = model;
      var index = options.at != null ? options.at :
                  this.comparator ? this.sortedIndex(model, this.comparator) :
                  this.length;
      this.models.splice(index, 0, model);
      model.bind('all', this._onModelEvent);
      this.length++;
      if (!options.silent) model.trigger('add', model, this, options);
      return model;
    }
1308765
function(models, options) {
      var i, args, length, model, existing, needsSort;
      var at = options && options.at;
      var sort = ((options && options.sort) == null ? true : options.sort);
      models = _.isArray(models) ? models.slice() : [models];

      // Turn bare objects into model references, and prevent invalid models
      // from being added.
      for (i = models.length - 1; i >= 0; i--) {
        if(!(model = this._prepareModel(models[i], options))) {
          this.trigger("error", this, models[i], options);
          models.splice(i, 1);
          continue;
        }
        models[i] = model;

        existing = model.id != null && this._byId[model.id];
        // If a duplicate is found, prevent it from being added and
        // optionally merge it into the existing model.
        if (existing || this._byCid[model.cid]) {
          if (options && options.merge && existing) {
            existing.set(model.attributes, options);
            needsSort = sort;
          }
          models.splice(i, 1);
          continue;
        }

        // Listen to added models' events, and index models for lookup by
        // `id` and by `cid`.
        model.on('all', this._onModelEvent, this);
        this._byCid[model.cid] = model;
        if (model.id != null) this._byId[model.id] = model;
      }

      // See if sorting is needed, update `length` and splice in new models.
      if (models.length) needsSort = sort;
      this.length += models.length;
      args = [at != null ? at : this.models.length, 0];
      push.apply(args, models);
      splice.apply(this.models, args);

      // Sort the collection if appropriate.
      if (needsSort && this.comparator && at == null) this.sort({silent: true});

      if (options && options.silent) return this;

      // Trigger `add` events.
      while (model = models.shift()) {
        model.trigger('add', model, this, options);
      }

      return this;
    }