Get only dataValues from Sequelize ORM

Gijo Varghese picture Gijo Varghese · Sep 23, 2017 · Viewed 47.7k times · Source

I'm using the sequelize ORM to fetch data from a PSQL DB. However, when I retrieve something, a whole bunch of data is given. The only data I want is inside 'dataValues'. Of course, I can use object.dataValues. But, is there any other good solutions?

I'm using Sequelize 4.10

Answer

Shivam picture Shivam · Sep 23, 2017

Yes you can

Model.findAll({
 raw: true,
 //Other parameters
});

would return just the data and not the model instance