Use of ColumnSet for setting up "SELECT" or "RETURNING" clauses #870
-
Given that I have the following ColumnSet: const returnCS = new pgp.helpers.ColumnSet([
'ingredientId',
'recipeId',
{
name: 'inclusionRatio',
cast: 'float',
},
{
name: 'pricePerKg',
cast: 'float',
},
]); The important bit being the using "returnCS.names" and the name filter will produce the column fields, but without the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
If you want to reuse function listColumns(cs : ColumnSet) : string {
return cs.columns.map(c => c.escapedName + (c.cast ? '::' + c.cast : '')).join(', ');
} |
Beta Was this translation helpful? Give feedback.
-
Types conversion is managed by pg-types, which you can access via |
Beta Was this translation helpful? Give feedback.
ColumnSet
is intended for the functions provided within thehelpers
namespace. "Select" isn't there, and not meant to be.If you want to reuse
ColumnSet
in that manner, you can create a function that will generate such syntax: