mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
🎨 fix format
This commit is contained in:
@@ -10,10 +10,7 @@ import pg = require('pg-promise/typescript/pg-subset');
|
||||
* @param {string[]} properties The properties it should include
|
||||
* @returns
|
||||
*/
|
||||
function getItemCopy(
|
||||
items: INodeExecutionData[],
|
||||
properties: string[],
|
||||
): IDataObject[] {
|
||||
function getItemCopy(items: INodeExecutionData[], properties: string[]): IDataObject[] {
|
||||
// Prepare the data to insert and copy it to be returned
|
||||
let newItem: IDataObject;
|
||||
return items.map(item => {
|
||||
@@ -69,9 +66,7 @@ export async function pgInsert(
|
||||
): Promise<Array<IDataObject[]>> {
|
||||
const table = getNodeParam('table', 0) as string;
|
||||
const schema = getNodeParam('schema', 0) as string;
|
||||
let returnFields = (getNodeParam('returnFields', 0) as string).split(
|
||||
',',
|
||||
) as string[];
|
||||
let returnFields = (getNodeParam('returnFields', 0) as string).split(',') as string[];
|
||||
const columnString = getNodeParam('columns', 0) as string;
|
||||
const columns = columnString.split(',').map(column => column.trim());
|
||||
|
||||
@@ -83,9 +78,7 @@ export async function pgInsert(
|
||||
const insertItems = getItemCopy(items, columns);
|
||||
|
||||
// Generate the multi-row insert query and return the id of new row
|
||||
returnFields = returnFields
|
||||
.map(value => value.trim())
|
||||
.filter(value => !!value);
|
||||
returnFields = returnFields.map(value => value.trim()).filter(value => !!value);
|
||||
const query =
|
||||
pgp.helpers.insert(insertItems, cs, te) +
|
||||
(returnFields.length ? ` RETURNING ${returnFields.join(',')}` : '');
|
||||
@@ -127,11 +120,7 @@ export async function pgUpdate(
|
||||
|
||||
// Generate the multi-row update query
|
||||
const query =
|
||||
pgp.helpers.update(updateItems, columns, table) +
|
||||
' WHERE v.' +
|
||||
updateKey +
|
||||
' = t.' +
|
||||
updateKey;
|
||||
pgp.helpers.update(updateItems, columns, table) + ' WHERE v.' + updateKey + ' = t.' + updateKey;
|
||||
|
||||
// Executing the query to update the data
|
||||
await db.none(query);
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
import {
|
||||
IDataObject,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
} from 'n8n-workflow';
|
||||
import { IDataObject, INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
||||
|
||||
import * as pgPromise from 'pg-promise';
|
||||
|
||||
@@ -130,8 +125,7 @@ export class Postgres implements INodeType {
|
||||
},
|
||||
},
|
||||
default: '*',
|
||||
description:
|
||||
'Comma separated list of the fields that the operation will return',
|
||||
description: 'Comma separated list of the fields that the operation will return',
|
||||
},
|
||||
|
||||
// ----------------------------------
|
||||
@@ -196,9 +190,7 @@ export class Postgres implements INodeType {
|
||||
database: credentials.database as string,
|
||||
user: credentials.user as string,
|
||||
password: credentials.password as string,
|
||||
ssl: !['disable', undefined].includes(
|
||||
credentials.ssl as string | undefined,
|
||||
),
|
||||
ssl: !['disable', undefined].includes(credentials.ssl as string | undefined),
|
||||
sslmode: (credentials.ssl as string) || 'disable',
|
||||
};
|
||||
|
||||
@@ -222,12 +214,7 @@ export class Postgres implements INodeType {
|
||||
// insert
|
||||
// ----------------------------------
|
||||
|
||||
const [insertData, insertItems] = await pgInsert(
|
||||
this.getNodeParameter,
|
||||
pgp,
|
||||
db,
|
||||
items,
|
||||
);
|
||||
const [insertData, insertItems] = await pgInsert(this.getNodeParameter, pgp, db, items);
|
||||
|
||||
// Add the id to the data
|
||||
for (let i = 0; i < insertData.length; i++) {
|
||||
|
||||
Reference in New Issue
Block a user