Reputation: 2828
Is there a way to order my results by the length (characters) of a column in sequelise ?
For example if I search for "lor" I would like to get result below:
results
________________
lor
lorem
lorem ip
lorem ips
lorem ipsum
Any suggestions gratefully received
Upvotes: 0
Views: 2414
Reputation: 30849
You can use ORDER
, e.g.:
order: [
[sequelize.fn('length', sequelize.col('column_name')), 'DESC']
]
Upvotes: 5