https://github.com/nicgirault/express-crud-router-sequelize-v6-connector
Sequelize v6 connector to [express-crud-router](https://github.com/lalalilo/express-crud-router)
https://github.com/nicgirault/express-crud-router-sequelize-v6-connector
Last synced: 7 months ago
JSON representation
Sequelize v6 connector to [express-crud-router](https://github.com/lalalilo/express-crud-router)
- Host: GitHub
- URL: https://github.com/nicgirault/express-crud-router-sequelize-v6-connector
- Owner: nicgirault
- Created: 2022-01-12T10:07:07.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-19T19:52:27.000Z (about 2 years ago)
- Last Synced: 2025-02-27T04:25:02.276Z (7 months ago)
- Language: TypeScript
- Size: 181 KB
- Stars: 2
- Watchers: 6
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
Awesome Lists containing this project
README
# express-crud-router-sequelize-v6-connector
Sequelize v6 connector to [express-crud-router](https://github.com/nicgirault/express-crud-router).
```ts
import crud from 'express-crud-router'
import sequelizeV6Crud from 'express-crud-router-sequelize-v6-connector'app.use(crud('/admin/users', sequelizeV6Crud(User)))
```## Install
```
npm install express-crud-router-sequelize-v6-connector
```## Search
express-crud-router-sequelize-v6-router exposes a default search helper function `sequelizeSearchFields`.
Here is an example:
```ts
import crud from 'express-crud-router'
import sequelizeCrud, {
simpleSequelizeSearch,
} from 'express-crud-router-sequelize-v6-connector'crud('/admin/users', sequelizeCrud(User), {
filters: {
q: simpleSequelizeSearch(User, ['address', 'zipCode', 'city']),
},
})
```When searching `some stuff`, records with a searchable field that contains `some stuff` will be returned.
The search is case insensitive by default (except for search fields of type `DataTypes.UUID` where exact matches are returned). You can customize the search to make it case sensitive:
```ts
import { Op } from 'sequelize'const search = simpleSequelizeSearch(
User,
['address', 'zipCode', 'city'],
Op.like
)
```## Contribute
See https://github.com/nicgirault/express-crud-router#contribute