Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SequelizeJS Soft Deleting

I can't figure out how the soft deleting works with SequelizeJS and I cannot find any documentation online.

I've already setup at a deletedAt column as

deletedAt: {
    type: Sequelize.DATE
}

but I don't know how to now setup the system so that MyModel.destroy(query) soft deletes it instead. Currently, it plainly removes the entry completely.

like image 480
Kousha Avatar asked Aug 07 '15 00:08

Kousha


Video Answer


1 Answers

http://docs.sequelizejs.com/en/latest/api/sequelize/#definemodelname-attributes-options-model

Set options.timestamps and options.paranoid to true - then sequelize will add the deletedAt column for you, and set it instead of deleting the row

like image 147
Jan Aagaard Meier Avatar answered Oct 17 '22 00:10

Jan Aagaard Meier