[Fixed] How to get a distinct value of a row with sequelize?

Issue

I have table with value

id country 
1  india
2  usa
3  india

I need to find the distinct values from the country column using sequelize.js

here my sample code…

Project.findAll({

    attributes: ['country'],
    distinct: true
}).then(function(country) {
     ...............
});

Is there any way to find the distict values

Solution

Try with this: https://github.com/sequelize/sequelize/issues/2996#issuecomment-141424712

Project.aggregate('country', 'DISTINCT', { plain: false })
.then(...)

Leave a Reply

(*) Required, Your email will not be published