mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-12 13:27:31 -08:00
⚡ Small improvement to Postgres-Node
This commit is contained in:
parent
d2a280d7b2
commit
0d5723f50a
|
@ -269,7 +269,7 @@ export class Postgres implements INodeType {
|
|||
|
||||
const table = this.getNodeParameter('table', 0) as string;
|
||||
const schema = this.getNodeParameter('schema', 0) as string;
|
||||
const returnFields = (this.getNodeParameter('returnFields', 0) as string).split(',') as string[];
|
||||
let returnFields = (this.getNodeParameter('returnFields', 0) as string).split(',') as string[];
|
||||
const columnString = this.getNodeParameter('columns', 0) as string;
|
||||
const columns = columnString.split(',').map(column => column.trim());
|
||||
|
||||
|
@ -281,7 +281,8 @@ export class Postgres implements INodeType {
|
|||
const insertItems = getItemCopy(items, columns);
|
||||
|
||||
// Generate the multi-row insert query and return the id of new row
|
||||
const query = pgp.helpers.insert(insertItems, cs, te) + ((returnFields[0] !== '') ? ` RETURNING ${returnFields.join(',')}` : '');
|
||||
returnFields = returnFields.map(value => value.trim()).filter(value => !!value);
|
||||
const query = pgp.helpers.insert(insertItems, cs, te) + (returnFields.length ? ` RETURNING ${returnFields.join(',')}` : '');
|
||||
|
||||
// Executing the query to insert the data
|
||||
const insertData = await db.manyOrNone(query);
|
||||
|
|
Loading…
Reference in a new issue