Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit a2ab89dd authored by GrayFawkes's avatar GrayFawkes
Browse files

fix: Update Client ne marche plus #39

parent efcd60db
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,6 @@ const dbG = require('../data/dbG.js')
module.exports = dbG.sequelize.define(
'client',
{
// uuid: { type: Sequelize.STRING(13) },
uuid: { type: Sequelize.UUID, defaultValue: Sequelize.UUIDV4, primaryKey: true },
numSS: { type: Sequelize.STRING(13) },
cleSS: { type: Sequelize.INTEGER(2) },
......
......@@ -5,8 +5,8 @@ const Client = require('../models/Client')
// Get all Clients
router.get('/clients', (req, res) => {
Client
.findAll().then(clients => { res.json(clients) })
Client.findAll()
.then(clients => { res.json(clients) })
.catch(err => { res.send('Error: ' + err) })
})
......@@ -16,14 +16,15 @@ router.post('/clients', (req, res) => {
res.status(400)
res.json({ error: 'Bad Data' })
} else {
Client
.create(req.body).then(() => { res.send('Client Added') })
Client.create(req.body)
.then(() => { res.send('Client Added') })
.catch(err => { res.send('error: ' + err) })
}
})
// Get Client
router.get('/clients/:uuid', (req, res) => {
Client
.findByPk(req.params.uuid)
Client.findByPk(req.params.uuid)
.then(client => { res.json(client) })
.catch(err => { res.send('Error: ' + err) })
})
......@@ -51,11 +52,10 @@ router.put('/clients/:uuid', (req, res) => {
error: 'Bad Data'
})
} else {
Client
.update(
req.body,
{ where: { uuid: req.params.uuid } }
)
Client.update(
req.body,
{ where: { uuid: req.params.uuid } }
)
.then(() => { res.send('Task Updated') })
.error(err => res.send(err))
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment