Reputation: 1175
How can I write select firstName || ' ' || lastName as name
in knexjs. Using raw this way .columns(knex.raw("fname || ' ' || lname as name"))
works, but is there any other way?
Upvotes: 9
Views: 8471
Reputation: 393
You could also just combine it in the code itself, why combine it in the query, when the same work can be done inline with the results of your query. It would be easier to read at that point, and you can do other stuff to the string before handing it out.
PS: You did ask "is there any other way?"
Upvotes: 0