2017-01-07 4 views
0

Ich habe Tabelle mit dem WertWie bekommt man einen bestimmten Wert einer Reihe mit Sequelize?

id country 
1 india 
2 usa 
3 india 

Ich brauche die unterschiedlichen Werte aus dem Land Spalte finden sequelize.js

hier meinen Beispielcode mit ...

Project.findAll({ 

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

es irgendein So finden Sie die Distikt-Werte

Antwort

6

können Sie verschiedene angeben, für ein oder mehrere Attribute 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) { }) 
+0

SequelizeDatabaseError mit: Syntaxfehler bei oder in der Nähe von "distinct" –

Verwandte Themen