3.1.2 • Published 5 years ago
ra-express-sequelize-backend v3.1.2
ra-express-sequelize-backend
Backend for React Admin simple rest client for Express and Sequelize.
Install
yarn add ra-express-sequelize-backend
Usage
Simple use case
import express from 'express'
import { User } from './models'
import crud from 'ra-express-sequelize-backend'
const app = new express()
app.use(crud('/admin/users', User))
Limit actions
import express from "express";
import { User } from "./models";
import crud, { Action } from "ra-express-sequelize-backend";
const app = new express();
app.use(
crud("/admin/users", User, {
actions: [Action.GET_LIST, Action.GET_ONE]
// or list disabled actions (this option override the action option)
disabledActions: [Action.DELETE]
})
);
Hooks
import express from 'express'
import { User } from './models'
import crud, { Action } from 'ra-express-sequelize-backend'
const app = new express()
app.use(
crud('/admin/users', User, {
hooks: {
[Action.GET_LIST]: {
after: async records => doSomething(records),
},
[Action.GET_ONE]: {
after: async record => doSomething(record),
},
[Action.CREATE]: {
before: async body => doSomething(body),
after: async record => doSomething(record),
},
[Action.UPDATE]: {
before: async (body, record) => doSomething(body, record),
after: async record => doSomething(record),
},
},
})
)
Search
We support React Admin searches that contains a string. For instance you can search users with emails that end with lalilo.com by prepending a %
character: %lalilo.com
.
contribute
How to publish a new version on npmjs.org
- update the version in package.json
- tag the commit
git tag -a vx.x.x
- push