Enable all CRUD(Create, Read, Update, and Delete) endpoints with this express middleware.
- Creates endpoints for
Get
Post
,Update
, andDelete
- Enables query strings for
Get
$ npm install mongoose-crud --save
import Crud from 'mongoose-crud';
const crud = new Crud(MongooseModel);
import Crud from 'mongoose-express-crud';
import express from 'express';
import User from './models/User'; //Model for endpoints
const crud = new Crud(User);
const app = express();
app.use('/users', crud.routes)
app.listen(3000, () => {
console.log('App listening on port 3000!')
});
note: If using require()
you must add .default
var Crud = require('mongoose-crud').default