How to get a distinct value of a row with sequelize?

You can specify distinct for one or more attributes using Sequelize.fn

Project.findAll({
    attributes: [
        // specify an array where the first element is the SQL function and the second is the alias
        [Sequelize.fn('DISTINCT', Sequelize.col('country')) ,'country'],

        // specify any additional columns, e.g. country_code
        // 'country_code'

    ]
}).then(function(country) {  })

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)