sequelize / express-example

A proposal for the usage of Sequelize within an Express.JS application.
MIT License
2.5k stars 773 forks source link

how to use DataType from req.body #88

Closed ninjasun closed 4 years ago

ninjasun commented 5 years ago

Hi all, I'm struggling around that thing. Basically, in my sql table, I have FLOAT and other types and in my req.body all the value are string (even 'null') as they should be. Can't figure out a way to convert them before call model.update. JSON.parse(req.body) breaks everything.

My request configuration comes from:

app.use(bodyParser.json());

app.use(bodyParser.urlencoded({
  extended: true
}));
app.use(fileUpload());

Thanks for any suggestion.

ikhsanalatsary commented 5 years ago

You don’t need JSON.parse(req.body) because it will handle by body parser.

papb commented 4 years ago

What @ikhsanalatsary said is correct (thanks!). You shouldn't have to do JSON.parse.

I will close this issue for housekeeping purposes, but @ninjasun let me know if you have any further issues. Thanks!