Categories
JavaScript Answers

How to convert entity to plain object with JavaScript Sequelize?

Spread the love

To convert entity to plain object with JavaScript Sequelize, we set the raw option to true.

For instance, we write

db.Sensors.findAll({
  where: {
    nodeId,
  },
  raw: true,
  nest: true,
}).success((sensors) => {
  console.log(sensors);
});

to call findAll to return objects by calling it with the raw option set to true.

We get the returned results from the sensors parameter in the success callback.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *