def delete(self, force=False):
if self.model is None:<EOL><INDENT>raise MissingModelError()<EOL><DEDENT>with db.session.begin_nested():<EOL><INDENT>before_record_delete.send(<EOL>current_app._get_current_object(),<EOL>record=self<EOL>)<EOL>if force:<EOL><INDENT>db.session.delete(self.model)<EOL><DEDENT>else:<EOL><INDENT>self.model.json = None<EOL>db.session.merge(self.model)<EOL><DEDENT><DEDENT>after_record_delete.send(<EOL>current_app._get_current_object(),<EOL>record=self<EOL>)<EOL>return self<EOL>
Delete a record.

        If `force` is ``False``, the record is soft-deleted: record data will
        be deleted but the record identifier and the history of the record will
        be kept. This ensures that the same record identifier cannot be used
        twice, and that you can still retrieve its history. If `force` is
        ``True``, then the record is completely deleted from the database.

        #. Send a signal :data:`invenio_records.signals.before_record_delete`
           with the current record as parameter.

        #. Delete or soft-delete the current record.

        #. Send a signal :data:`invenio_records.signals.after_record_delete`
           with the current deleted record as parameter.

        :param force: if ``True``, completely deletes the current record from
               the database, otherwise soft-deletes it.
        :returns: The deleted :class:`Record` instance.