All Projects → lalalilo → Express Sequelize Crud

lalalilo / Express Sequelize Crud

Simply expose resource CRUD (Create Read Update Delete) routes for Express & Sequelize. Compatible with React Admin Simple Rest Data Provider

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Express Sequelize Crud

express-crud-router
Simply expose resource CRUD (Create Read Update Delete) routes for Express & Sequelize. Compatible with React Admin Simple Rest Data Provider
Stars: ✭ 109 (+67.69%)
Mutual labels:  crud, expressjs, sequelize, express-js, react-admin
Mean Stack Angular6 Crud Example
MEAN Stack Angular 6 CRUD Web Application
Stars: ✭ 69 (+6.15%)
Mutual labels:  express, expressjs, crud
Online Bling
Stars: ✭ 9 (-86.15%)
Mutual labels:  sequelize, express, express-js
Node Production
Take Your Node.js Project to The Production Environment (VPS/Dedicated Server).
Stars: ✭ 35 (-46.15%)
Mutual labels:  express, expressjs, express-js
Node Express Postgresql Server
Basic Node with Express + PostgreSQL Server
Stars: ✭ 74 (+13.85%)
Mutual labels:  express, expressjs, express-js
Node Express Postgresql Sequelize
Node.js, Express.js, Sequelize.js and PostgreSQL RESTful API
Stars: ✭ 148 (+127.69%)
Mutual labels:  sequelize, express, expressjs
Mean Stack Angular5 Crud
MEAN Stack (Angular 5) CRUD Web Application Example
Stars: ✭ 107 (+64.62%)
Mutual labels:  express, expressjs, crud
Serverless Express
Run Node.js web applications and APIs using existing application frameworks on AWS #serverless technologies such as Lambda, API Gateway, Lambda@Edge, and ALB.
Stars: ✭ 4,265 (+6461.54%)
Mutual labels:  express, expressjs, express-js
todo-list
A practical web application built with Node.js, Express, and MySQL for you to readily record, view, and manage your tasks with an account: Create, view, edit, delete, filter, and sort expenses are as easy as pie 🥧
Stars: ✭ 18 (-72.31%)
Mutual labels:  crud, expressjs, sequelize
Mern Stack Authentication
Secure MERN Stack CRUD Web Application using Passport.js Authentication
Stars: ✭ 60 (-7.69%)
Mutual labels:  express, expressjs, crud
Practicalnode
Practical Node.js, 1st and 2nd Editions [Apress] 📓
Stars: ✭ 3,694 (+5583.08%)
Mutual labels:  express, expressjs, express-js
Generator Express No Stress
🚂 A Yeoman generator for Express.js based 12-factor apps and apis
Stars: ✭ 534 (+721.54%)
Mutual labels:  express, expressjs, express-js
Mean Angular5 Passport Authentication
Securing MEAN Stack (Angular 5) Web Application using Passport Authentication
Stars: ✭ 24 (-63.08%)
Mutual labels:  express, expressjs
React Express Fullstack
Full stack (mostly unopinionated) starter pack with React+Redux and Expressjs
Stars: ✭ 23 (-64.62%)
Mutual labels:  sequelize, express
Pretzel
Javascript full-stack framework for Big Data visualisation and analysis
Stars: ✭ 26 (-60%)
Mutual labels:  express, expressjs
Rest Api Nodejs Mongodb
A boilerplate for REST API Development with Node.js, Express, and MongoDB
Stars: ✭ 672 (+933.85%)
Mutual labels:  express, expressjs
Express
Express + Sequelize + Winston + Jasmine + TypeScript + Webpack MVC Boilerplate
Stars: ✭ 9 (-86.15%)
Mutual labels:  sequelize, express
Webpack2 Express Heroku Starter
Starter app using Webpack 2, Express, setup to deploy to Heroku.
Stars: ✭ 12 (-81.54%)
Mutual labels:  express, expressjs
Openuserjs.org
The home of FOSS user scripts.
Stars: ✭ 632 (+872.31%)
Mutual labels:  express, expressjs
Mean Angular4 Chat App
MEAN stack with Angular 4 Chat App
Stars: ✭ 41 (-36.92%)
Mutual labels:  express, expressjs

express-sequelize-crud

import crud, { sequelizeCrud } from 'express-sequelize-crud'

app.use(crud('/admin/users', sequelizeCrud(User)))

Expose resource CRUD (Create Read Update Delete) routes for Express & Sequelize (and other ORMs in v6+). Compatible with React Admin Simple Rest Data Provider

codecov CircleCI

Install

yarn add express-sequelize-crud

Usage

Simple use case

import express from 'express'
import crud, { sequelizeCrud } from 'express-sequelize-crud'
import { User } from './models'

const app = new express()
app.use(crud('/admin/users', sequelizeCrud(User)))

Limit actions

import express from 'express'
import crud, { sequelizeCrud } from 'express-sequelize-crud'
import { User } from './models'

const app = new express()
app.use(
  crud('/admin/users', {
    ...sequelizeCrud(User),
    destroy: null,
  })
)

Custom filters

Custom filters such as case insensitive filter can be perform like this:

import express from 'express'
import { Op } from 'sequelize'
import crud, { sequelizeCrud } from 'express-sequelize-crud'
import { User } from './models'

const app = new express()
app.use(
  crud('/admin/users', sequelizeCrud(User), {
    filters: {
      email: value => ({
        [Op.iLike]: value,
      }),
    },
  })
)

Custom behavior & other ORMs

import express from 'express'
import crud from 'express-sequelize-crud'
import { User } from './models'

const app = new express()
app.use(
  crud('/admin/users', {
    getList: ({ filter, limit, offset, order }) =>
      User.findAndCountAll({ limit, offset, order, where: filter }),
    getOne: id => User.findByPk(id),
    create: body => User.create(body),
    update: (id, body) => User.update(body, { where: { id } }),
    destroy: id => User.destroy({ where: { id } }),
  })
)

Search

Autocomplete

When using react-admin autocomplete reference field, a request is done to the API with a q filter. Thus, when using the autocomplete field in react-admin, you must specify the behavior to search the records. This could looks like:

app.use(
  crud('/admin/users', {
    search: async (q, limit) => {
      const { rows, count } = await User.findAndCountAll({
        limit,
        where: {
          [Op.or]: [
            { address: { [Op.iLike]: `${q}%` } },
            { zipCode: { [Op.iLike]: `${q}%` } },
            { city: { [Op.iLike]: `${q}%` } },
          ],
        },
      })

      return { rows, count }
    },
  })
)

express-sequelize-crud, exposes a default search helper that you can use like this:

import crud, {
  sequelizeCrud,
  sequelizeSearchFields,
} from 'express-sequelize-crud'

crud('/admin/users', {
  ...sequelizeCrud(User),
  search: sequelizeSearchFields(User, ['address', 'zipCode', 'city']),
})

When searching some stuff, the following records will be returned in this order:

  1. records with a searchable field that contains some stuff
  2. records that have searchable fields that contain both some and stuff
  3. records that have searchable fields that contain one of some or stuff

The search is case insensitive by default. You can customize the search to make it case sensitive or use a scope:

import { Op } from 'sequelize'

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

Contribute

This lib uses semantic-release. You need to write your commits following this nomenclature:

  • feat: A new feature
  • fix: A bug fix
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, - formatting, missing semi-colons, etc)
  • refactor: A code change that neither fixes a bug nor adds a feature
  • perf: A code change that improves performance
  • test: Adding missing or correcting existing tests
  • chore: Changes to the build process or auxiliary tools and libraries such as documentation generation

To trigger a major version release write in the core of the commit message:

feat: my commit

BREAKING CHANGE: detail here
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].