I am new to Sequelize (a node.js ORM) and am wondering if the following code is safe:
var models = require('../models');
var router = require('express').Router();
router.post('/', function(req, res, next){
models.Account
.create(req.body)
.then(function(result){
res.status(200)
.send(result)
.end();
}).catch(next);
});
If you use this, could it be unsafe? Another solution:
var models = require('../models');
var router = require('express').Router();
router.post('/', function(req, res, next){
models.Account
.create({
username: req.body.username,
accountname: req.body.accountname,
level: req.body.level
})
.then(function(result){
res.status(200)
.send(result)
.end();
}).catch(next);
});
So, basically my question is: Is it safe to use the full body of the request as an input to the function model.create()(and model.set(), and model.build())?
source
share