Skip to content

Instantly share code, notes, and snippets.

@giiska
Created November 10, 2015 10:22
Show Gist options
  • Save giiska/da9c5674eeec2f8dfbba to your computer and use it in GitHub Desktop.
Save giiska/da9c5674eeec2f8dfbba to your computer and use it in GitHub Desktop.
Sequelize order findAll result by giving `where in` id array
// ids is array
var idsCopy = clone(ids);
idsCopy.unshift('FIELD', Sequelize.col('id'));
db.table.findAll({
where: { id: ids },
order: [[Sequelize.fn.apply(this, idsCopy) ]]
}).then(function(users) {
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment