mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
👕 Fix lint issue
This commit is contained in:
@@ -11,7 +11,7 @@ import { ITables } from './TableInterface';
|
||||
*/
|
||||
export function copyInputItem(
|
||||
item: INodeExecutionData,
|
||||
properties: string[]
|
||||
properties: string[],
|
||||
): IDataObject {
|
||||
// Prepare the data to insert and copy it to be returned
|
||||
const newItem: IDataObject = {};
|
||||
@@ -36,7 +36,7 @@ export function createTableStruct(
|
||||
getNodeParam: Function,
|
||||
items: INodeExecutionData[],
|
||||
additionalProperties: string[] = [],
|
||||
keyName?: string
|
||||
keyName?: string,
|
||||
): ITables {
|
||||
return items.reduce((tables, item, index) => {
|
||||
const table = getNodeParam('table', index) as string;
|
||||
@@ -69,7 +69,7 @@ export function createTableStruct(
|
||||
*/
|
||||
export function executeQueryQueue(
|
||||
tables: ITables,
|
||||
buildQueryQueue: Function
|
||||
buildQueryQueue: Function,
|
||||
): Promise<any[]> { // tslint:disable-line:no-any
|
||||
return Promise.all(
|
||||
Object.keys(tables).map(table => {
|
||||
@@ -79,11 +79,11 @@ export function executeQueryQueue(
|
||||
table,
|
||||
columnString,
|
||||
items: tables[table][columnString],
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
return Promise.all(columnsResults);
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -112,7 +112,7 @@ export function extractUpdateSet(item: IDataObject, columns: string[]): string {
|
||||
column =>
|
||||
`${column} = ${
|
||||
typeof item[column] === 'string' ? `'${item[column]}'` : item[column]
|
||||
}`
|
||||
}`,
|
||||
)
|
||||
.join(',');
|
||||
}
|
||||
|
||||
@@ -268,10 +268,10 @@ export class MicrosoftSql implements INodeType {
|
||||
return pool
|
||||
.request()
|
||||
.query(
|
||||
`INSERT INTO ${table}(${columnString}) VALUES ${values};`
|
||||
`INSERT INTO ${table}(${columnString}) VALUES ${values};`,
|
||||
);
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
returnItems = items;
|
||||
@@ -281,13 +281,13 @@ export class MicrosoftSql implements INodeType {
|
||||
// ----------------------------------
|
||||
|
||||
const updateKeys = items.map(
|
||||
(item, index) => this.getNodeParameter('updateKey', index) as string
|
||||
(item, index) => this.getNodeParameter('updateKey', index) as string,
|
||||
);
|
||||
const tables = createTableStruct(
|
||||
this.getNodeParameter,
|
||||
items,
|
||||
['updateKey'].concat(updateKeys),
|
||||
'updateKey'
|
||||
'updateKey',
|
||||
);
|
||||
await executeQueryQueue(
|
||||
tables,
|
||||
@@ -308,14 +308,14 @@ export class MicrosoftSql implements INodeType {
|
||||
const setValues = extractUpdateSet(item, columns);
|
||||
const condition = extractUpdateCondition(
|
||||
item,
|
||||
item.updateKey as string
|
||||
item.updateKey as string,
|
||||
);
|
||||
|
||||
return pool
|
||||
.request()
|
||||
.query(`UPDATE ${table} SET ${setValues} WHERE ${condition};`);
|
||||
});
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
returnItems = items;
|
||||
@@ -343,9 +343,9 @@ export class MicrosoftSql implements INodeType {
|
||||
deleteKey => {
|
||||
const deleteItemsList = chunk(
|
||||
tables[table][deleteKey].map(item =>
|
||||
copyInputItem(item as INodeExecutionData, [deleteKey])
|
||||
copyInputItem(item as INodeExecutionData, [deleteKey]),
|
||||
),
|
||||
1000
|
||||
1000,
|
||||
);
|
||||
const queryQueue = deleteItemsList.map(deleteValues => {
|
||||
return pool
|
||||
@@ -353,21 +353,21 @@ export class MicrosoftSql implements INodeType {
|
||||
.query(
|
||||
`DELETE FROM ${table} WHERE ${deleteKey} IN ${extractDeleteValues(
|
||||
deleteValues,
|
||||
deleteKey
|
||||
)};`
|
||||
deleteKey,
|
||||
)};`,
|
||||
);
|
||||
});
|
||||
return Promise.all(queryQueue);
|
||||
}
|
||||
},
|
||||
);
|
||||
return Promise.all(deleteKeyResults);
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
const rowsDeleted = flatten(queriesResults).reduce(
|
||||
(acc: number, resp: mssql.IResult<object>): number =>
|
||||
(acc += resp.rowsAffected.reduce((sum, val) => (sum += val))),
|
||||
0
|
||||
0,
|
||||
);
|
||||
|
||||
returnItems = this.helpers.returnJsonArray({
|
||||
|
||||
Reference in New Issue
Block a user