Tuesday 16 May 2017

Response code if query runs successfully but record is not found

I am using sequelize with expressjs, I use find function of sequelize, it runs successfully. If query runs successfully but does not find any record what should be the response code? Because if no record is found sequelize returns null.

  db.Property.find({
   where: {
    country: req.query.country,
   },
  })
  .then((property) => {
   if (property) {
    res.json({ status: true }); // send 200 response if record found
   } else {
    // What should be Status Code if record is not found.
   }
  });

So question is what should be status code if record is not found from db?



via Hassan Ajaz

No comments:

Post a Comment