Link to home
Start Free TrialLog in
Avatar of Omar Martin
Omar MartinFlag for United States of America

asked on

"No rows affected" when trying to Update Mysql table.

I am updating records using sequelize. I am testing the backend with postman.  The code seems to work as there is no error however when testing it in postman, no rows are affected (updated). I have used both put and patch methods, however, I received the same results. Perhaps, there is an error in the code that I am missing.

Here is the code:

router.put('/editstation/:id', (req, res) => {

             let newStation = req.body.station;
             let newAddress = req.body.address;
             let newMonthlycstoresales = req.body.monthlycstoresales;
             let newOperator = req.body.operator;
             let newTopsku = req.body.topsku;


   
   let values = {Station: newStation, Address: newAddress, monthlycstoresales: newMonthlycstoresales, Operator: newOperator, topsku:newTopsku};

   let selector = {
       where: {id: req.params.id}
   }
   Store.update(values, selector)
   .then((updatedPost)=>{
       console.log(updatedPost);
       res.json({
           "message": updatedPost
       })
   })
   .catch(err => {
       res.json({
           "message": err
       })
   })

});

Here is the json test in postman

{
      "ID": 6,
      "Station": "Rargain jiack",
      "Operator": "Dilly"
}

Here are the results:

{
    "message": [
        0
    ]
}
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Omar Martin

ASKER

Thank you Julian.....it was the capitalization. Much appreciated.
You are welcome.