I am trying to order by my data based on an attribute. Here I have a model name Farmer and I am ordering this model by name. The query is like this:
Farmer.findAll({order: [['name', 'ASC']]})
Which is ordering data case sensitively. But I want to order this case insensitively. How can i get it?
You could use sequelize.fn
( http://docs.sequelizejs.com/class/lib/sequelize.js~Sequelize.html#static-method-fn ) to transform your name to lowercase
Farmer.findAll({
order: [
[
Sequelize.fn('lower', Sequelize.col('name')),
'ASC',
],
],
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.