From 3bf34cffa90a1810b265d5ce0872d25db13a658c Mon Sep 17 00:00:00 2001 From: Ben Hesseldieck Date: Thu, 9 Jul 2020 17:16:45 +0200 Subject: [PATCH] :art: fix format --- .../credentials/Questdb.credentials.ts | 8 ++---- .../nodes/Postgres/Postgres.node.functions.ts | 19 +++---------- .../nodes/Postgres/Postgres.node.ts | 21 +++------------ .../nodes-base/nodes/QuestDB/QuestDB.node.ts | 27 ++++--------------- 4 files changed, 15 insertions(+), 60 deletions(-) diff --git a/packages/nodes-base/credentials/Questdb.credentials.ts b/packages/nodes-base/credentials/Questdb.credentials.ts index 5cd60f960a..3672f6204d 100644 --- a/packages/nodes-base/credentials/Questdb.credentials.ts +++ b/packages/nodes-base/credentials/Questdb.credentials.ts @@ -1,8 +1,4 @@ -import { - ICredentialType, - NodePropertyTypes, -} from 'n8n-workflow'; - +import { ICredentialType, NodePropertyTypes } from 'n8n-workflow'; export class QuestDB implements ICredentialType { name = 'questdb'; @@ -59,7 +55,7 @@ export class QuestDB implements ICredentialType { { name: 'verify-full (not implemented)', value: 'verify-full', - } + }, ], default: 'disable', }, diff --git a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts index b07835d1f6..fb4c50051c 100644 --- a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts +++ b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts @@ -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> { 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); diff --git a/packages/nodes-base/nodes/Postgres/Postgres.node.ts b/packages/nodes-base/nodes/Postgres/Postgres.node.ts index 702799c5c2..847620a6fa 100644 --- a/packages/nodes-base/nodes/Postgres/Postgres.node.ts +++ b/packages/nodes-base/nodes/Postgres/Postgres.node.ts @@ -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++) { diff --git a/packages/nodes-base/nodes/QuestDB/QuestDB.node.ts b/packages/nodes-base/nodes/QuestDB/QuestDB.node.ts index 93dcdbe66d..bc8af9f17c 100644 --- a/packages/nodes-base/nodes/QuestDB/QuestDB.node.ts +++ b/packages/nodes-base/nodes/QuestDB/QuestDB.node.ts @@ -1,18 +1,9 @@ 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'; -import { - pgInsert, - pgQuery, - pgUpdate, -} from '../Postgres/Postgres.node.functions'; +import { pgInsert, pgQuery, pgUpdate } from '../Postgres/Postgres.node.functions'; export class QuestDB implements INodeType { description: INodeTypeDescription = { @@ -134,8 +125,7 @@ export class QuestDB 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', }, // ---------------------------------- @@ -200,9 +190,7 @@ export class QuestDB 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', }; @@ -226,12 +214,7 @@ export class QuestDB 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++) {