imrvasishtha
imrvasishtha

Reputation: 99

How to hard delete by bookshelf when soft delete enable

Suppose, I want to delete temporarily so I can use soft delete by bookshelf, but in that case when I need to delete the permanently row of the table. So, How I can do that when soft delete is enabled for model.

`use strict`

const Bookshelf = require('../bookshelf');

module.exports = Bookshelf.model('contactUs', {
    tableName: `contact_us`,
    hasTimestamps: ['created_at', 'updated_at'],
    softDelete: true,
    hidden: ['deleted_at'],

    parse: function (response) {
        if (response.allowUseOfMyContactInformation != null) {
            response.allowUseOfMyContactInformation = !!+response.allowUseOfMyContactInformation
        }
        return response;

    }
})

Upvotes: 0

Views: 965

Answers (1)

Oyedeji Peace
Oyedeji Peace

Reputation: 306

If you want to delete something for good, even if the model has soft deleting enabled, set hardDelete to true e.g.

new contactUs({ id }).destroy({ hardDelete: true })

Upvotes: 2

Related Questions