MCPcopy Create free account
hub / github.com/porsager/postgres / select

Function select

cf/src/types.js:137–152  ·  view source on GitHub ↗
(first, rest, parameters, types, options)

Source from the content-addressed store, hash-verified

135}
136
137function select(first, rest, parameters, types, options) {
138 typeof first === 'string' && (first = [first].concat(rest))
139 if (Array.isArray(first))
140 return escapeIdentifiers(first, options)
141
142 let value
143 const columns = rest.length ? rest.flat() : Object.keys(first)
144 return columns.map(x => {
145 value = first[x]
146 return (
147 value instanceof Query ? fragment(value, parameters, types, options) :
148 value instanceof Identifier ? value.value :
149 handleValue(value, parameters, types, options)
150 ) + ' as ' + escapeIdentifier(options.transform.column.to ? options.transform.column.to(x) : x)
151 }).join(',')
152}
153
154const builders = Object.entries({
155 values,

Callers

nothing calls this directly

Calls 4

escapeIdentifiersFunction · 0.70
fragmentFunction · 0.70
handleValueFunction · 0.70
escapeIdentifierFunction · 0.70

Tested by

no test coverage detected