I am trying to order my collection fetch results by a column which is working so far, but I want the sorting to be case insensitive. I've gone through the bookshelf docs and searched around here and other forums to no avail. Is something that requires some raw Knex insertion? Any help is much appreciated.
Here is my code:
new Recipes().query('orderBy', 'name', 'asc').fetch({
withRelated: [
{ instructions: (query) => { query.orderBy('step_number'); }},
'tags',
'ingredients',
'ingredients.alternatives',
'ingredients.tags'
]
});
I'd like to do something like:
new Recipes().query('orderByIgnoreCase', 'name', 'asc').fetch({
withRelated: [
{ instructions: (query) => { query.orderBy('step_number'); }},
'tags',
'ingredients',
'ingredients.alternatives',
'ingredients.tags'
]
});
OR:
new Recipes().query('orderBy', LOWER('name'), 'asc').fetch({
withRelated: [
{ instructions: (query) => { query.orderBy('step_number'); }},
'tags',
'ingredients',
'ingredients.alternatives',
'ingredients.tags'
]
});
via Randall Spencer
No comments:
Post a Comment