express-crud-router-sequelize-v6-connector
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

express-crud-router-sequelize-v6-connector

Sequelize v6 connector to express-crud-router.

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:

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:

import { Op } from 'sequelize'

const search = simpleSequelizeSearch(
  User,
  ['address', 'zipCode', 'city'],
  Op.like
)

Contribute

See https://github.com/nicgirault/express-crud-router#contribute

Package Sidebar

Install

npm i express-crud-router-sequelize-v6-connector

Weekly Downloads

63

Version

2.0.0

License

MIT

Unpacked Size

8.73 kB

Total Files

8

Last publish

Collaborators

  • lalilo-user
  • nicgirault