controller/store/update/information/name

mail@pastecode.io avatar
unknown
plain_text
15 days ago
670 B
3
Indexable
Never
const db = require('../../../../models/index');

const name = (req, res) => {

  const storeID = req.body.store_id;
  const storeName = req.body.name;

  const updateStoreName = (storeID, storeName, t) => {
    return db.store.update({
      name: storeName
    }, { transaction: t })
      .catch(err => {
        throw new Error("[Fail to udpate store name" + err)
      })
  }

  return db.sequelize.transaction(t => {
    return updateStoreName(storeID, storeName, t)
  })
    .then(() => {
      return res.status(200).send("Successfully update store name")
    })
    .catch(err => {
      return res.status(400).send(err.message)
    })
};

module.exports = name;
Leave a Comment