如何合并 knex.js 中的列
How to combine columns in knex.js
如何在 knexjs 中编写 select firstName || ' ' || lastName as name
。以这种方式使用 raw .columns(knex.raw("fname || ' ' || lname as name"))
可行,但还有其他方法吗?
您也可以将它合并到代码本身,为什么要将它合并到查询中,因为相同的工作可以与您的查询结果内联完成。到那时它会更容易阅读,你可以在分发之前对字符串做其他事情。
PS:你确实问过"is there any other way?"
如何在 knexjs 中编写 select firstName || ' ' || lastName as name
。以这种方式使用 raw .columns(knex.raw("fname || ' ' || lname as name"))
可行,但还有其他方法吗?
您也可以将它合并到代码本身,为什么要将它合并到查询中,因为相同的工作可以与您的查询结果内联完成。到那时它会更容易阅读,你可以在分发之前对字符串做其他事情。
PS:你确实问过"is there any other way?"