Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eclass/sequelize-soft-delete
Sequelize model plugin for add soft-delete method
https://github.com/eclass/sequelize-soft-delete
Last synced: about 1 month ago
JSON representation
Sequelize model plugin for add soft-delete method
- Host: GitHub
- URL: https://github.com/eclass/sequelize-soft-delete
- Owner: eclass
- License: mit
- Created: 2018-05-07T17:06:46.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-11-06T20:09:05.000Z (about 2 months ago)
- Last Synced: 2024-11-17T05:05:00.010Z (about 2 months ago)
- Language: JavaScript
- Size: 683 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 51
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# sequelize-soft-delete
[![npm version](https://img.shields.io/npm/v/sequelize-soft-delete.svg?style=flat-square)](https://www.npmjs.com/package/sequelize-soft-delete)
[![npm downloads](https://img.shields.io/npm/dm/sequelize-soft-delete.svg?style=flat-square)](https://www.npmjs.com/package/sequelize-soft-delete)
[![devDependency Status](https://img.shields.io/david/dev/eclass/sequelize-soft-delete.svg?style=flat-square)](https://david-dm.org/eclass/sequelize-soft-delete#info=devDependencies)> Sequelize model plugin for add soft-delete method
## Installation
```bash
npm i sequelize-soft-delete
```## Use
```js
// model.js
const sequelizeSoftDelete = require('sequelize-soft-delete')module.exports = (sequelize, DataTypes) => {
const MyModel = sequelize.define(
'MyModel',
{
deleted: {
type: DataTypes.INTEGER(1),
defaultValue: 0
}
},
{
defaultScope: {
where: {
deleted: 0
}
}
}
)
const options = {field: 'deleted', deleted: 1}
sequelizeSoftDelete.softDelete(MyModel, options)
return MyModel
}// controller.js
const updated = await db.MyModel.softDelete({ where: { id: 1 } })
```## License
[MIT](https://tldrlegal.com/license/mit-license)