1.0.3 • Published 4 years ago
mongoose-cruds-router v1.0.3
mongoose-cruds-router
A fast way to add all cruds apis for a mongoose model
How to install
npm i mongoose-cruds-router --save
How to use
const {addMongooseRouter} = require('mongoose-cruds-router'); app.use(addMongooseRouter(MongooseModel, options));
Options possible values
- path, name of the api, by default it will be the model name, like /users
- prefix, prefix of the apis, by default it will be empty, you can pass /api/v1 or something like that
- skipDelete, pass as true if you want to skip delete api, false by default
- skipAdd, pass as true if you want to skip add api, false by default
- skipUpdate, pass as true if you want to skip update api, false by default
- skipFind, pass as true if you want to skip find api, false by default
- skipGet, pass as true if you want to skip get api, false by default
Default Apis
- GET /model , returns list of objects, you can pass search params
- GET /model/id, returns the object on that id
- POST /model, pass params as form to create object
- PUT /model/id, pass params needed to update on object under this id
- DELETE /model/id, deletes object on this id
Features
- Joi validation will be added on the basis of model schema on apis
- It does't take any databse credentials, or db objects, everything will be in your code. Just pass mongoose model, it will use the model to add apis, functions.
- On error, it will pass error object on next, you can manage errir handle on your code, it will do, next(err)
People
Author Muhammad Aadil