The code below was extracted
from the class.
Knowing that you have the
following project hierarchy.
Analyze the code below and
choose only the correct answers
There are 4 correct answers.Each correct answer adds 25% to the question's grade.Each wrong answer chosen reduces the question's grade by 25%.
File: server\app\controllers\product.controller.js
- const db = require('../models')
- const Product = db.products
- const Op = db.Sequelize.Op
- exports.update = (req, res) => {
- const id = req.params.id;
- Product.update(req.body, {
- where: { id: id }
- })
- .then(num => {
- if (num == 1) {
- res.send({
- message: 'Product was updated successfully.'
- });
- } else {
- res.send({
- message: `Cannot update product with id=${id}. Maybe product was not found or is empty!`
- });
- }
- })
- .catch(err => {
- res.status(500).send({
- message: `Error updating Product with id=${id}`
- })
- })
- }