I have a model (Article
) with a field (the name is type
) of type ENUM('source', 'translated')
and would like to return 1 article ordered by the type field. Source articles should be returned before translated articles. Something like:
Article.findOne(order: [
{
type: [
'source',
'translated'
]
}
]);
Unfortunately there appears to be no built-in solution for sorting by enums. Instead I probably have to sort by case, but I couldn't find any documentation on how to do this with Sequelize.
What would be the conventional approach here?