ra-data-simple-rest-expressjs-mongoose
TypeScript icon, indicating that this package has built-in type declarations

0.1.5 • Public • Published

Express Mongoose

Build API for React admin simple rest client in a project using Express and Mongoose.

Install

npm install --save ra-data-simple-rest-expressjs-mongoose

Usage

const express = require("express");
const bodyParser = require("body-parser");
const rest = require("ra-data-simple-rest-expressjs-mongoose");

const User = require("./models/User");

const app = express();
app.use(bodyParser.json({ limit: "50mb" }));

rest.default({
  router: app,
  route: "/user",
  model: User,
  actions: [rest.CREATE, rest.GET_LIST, rest.GET_ONE, rest.UPDATE, rest.DELETE],
  middlewares: [],
  select: "+name +username -password"
});

Options:

The default function takes mandatory object that contain following keys:

Property Type Default Description
router express instance null instance of express
route string "" api route
model Mongoose.Model null Mongoose model to create APIs for
actions array [rest.CREATE, rest.GET_LIST, rest.GET_ONE, rest.UPDATE, rest.DELETE] apis to expose
middlewares array [] any middlewares to apply on apis
select string "" columns to select

Package Sidebar

Install

npm i ra-data-simple-rest-expressjs-mongoose

Weekly Downloads

0

Version

0.1.5

License

ISC

Unpacked Size

21.3 kB

Total Files

11

Last publish

Collaborators

  • vikas26