Last active
October 2, 2019 12:39
-
-
Save EdByrnee/8eaa324d4aee8dc4cfec8a6849da4580 to your computer and use it in GitHub Desktop.
Sequelize on rails basic CRUD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var router = express.Router(); | |
const models = require("../../models"); | |
const Model = models.RiskAssesmentArea; | |
router.get("/:id", async (req,res,next)=>{ | |
Model.findById({},req,res,next); | |
}) | |
router.get("/", async (req,res,next)=>{ | |
Model.findAndPageAll({ | |
paranoid: false | |
}, req,res,next) | |
}) | |
router.patch("/:id", async (req,res,next)=>{ | |
Model.updateWhitelisted(["risk_assesment_area_name"],req,res,next); | |
}) | |
router.delete("/:id", async (req,res,next)=>{ | |
Model.destroyIfFound(req,res,next); | |
}) | |
router.post("/", async (req,res,next)=>{ | |
Model.createWithWhitelisted(['risk_assesment_area_name'],req,res,next); | |
}) | |
module.exports = router; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment