3.1.2 • Published 5 years ago

ra-express-sequelize-backend v3.1.2

Weekly downloads
14
License
MIT
Repository
github
Last release
5 years ago

ra-express-sequelize-backend

Backend for React Admin simple rest client for Express and Sequelize.

codecov CircleCI

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
3.1.2

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.0.1

5 years ago

3.0.0

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago