1

i want to update a record of my model in DB

update: async function (req, res, next) {

await Place.update({'id':1})
  .set({
    title: req.param('title'),
  })
  .fetch()
  .then(function place_updated(updated_place){
    res.json({'status':true, 'result':updated_place});
    })
  .catch(function(err) {
    if (err) {
      return res.json({'status': false, 'errors': err.Errors});
    }
  });
},  

I'm sure that there is a record with the ID 1 in the database
But i get message Not Found !!!
please help me
thank you

mas cm
  • 131
  • 2
  • 10
  • What database are you using? Maybe this helps: https://stackoverflow.com/questions/22401062/how-to-show-queries-in-console-log-using-sails – fardjad Apr 01 '18 at 10:38
  • @fardjad i use mysql db – mas cm Apr 01 '18 at 10:45
  • I suggest you to run your script with `LOG_QUERIES` environment variable set to `TRUE` (as mentioned in the link) and check if the ORM generates the query you expect. – fardjad Apr 01 '18 at 10:55
  • @fardjad Please tell exactly which path should be the LOG_QUERIES and where to see the output – mas cm Apr 01 '18 at 11:27
  • 1
    `LOG_QUERIES` is an environment variable. If you're on ***nix**, open your favorite Terminal Emulator and run `LOG_QUERIES=true node /path/to/your/script.js`. In case you're using **Windows**, open a Command Prompt window and run `set LOG_QUERIES=true && node \path\to\your\script.js`. Queries will be displayed in the console. – fardjad Apr 01 '18 at 11:32

0 Answers0