Q:

Sequelize: How to order results by CHAR LENGTH?

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

A:

You can use ORDER, e.g.:
order: [
    [sequelize.fn('length', sequelize.col('column_name')), 'DESC']
 ]

