Categories
JavaScript Answers

How to get only dataValues from Node Sequelize ORM?

Spread the love

To get only dataValues from Node Sequelize ORM, we call the findById method.

For instance, we write

const data = await Model.findById(1);
console.log(data.get({ plain: true }));

to call findById to get the item by ID.

And then we call data.get with { plain: true } to return a plain object version of the result.

By John Au-Yeung

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

Leave a Reply

Your email address will not be published.