n8n/packages/nodes-base/nodes/Snowflake/GenericFunctions.ts
Tomi Turtiainen 9a1cc56806
fix: Set '@typescript-eslint/return-await' rule to 'always' for node code (no-changelog) (#8363)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
2024-01-17 17:08:50 +02:00

28 lines
729 B
TypeScript

import type snowflake from 'snowflake-sdk';
export async function connect(conn: snowflake.Connection) {
return await new Promise<void>((resolve, reject) => {
conn.connect((error) => (error ? reject(error) : resolve()));
});
}
export async function destroy(conn: snowflake.Connection) {
return await new Promise<void>((resolve, reject) => {
conn.destroy((error) => (error ? reject(error) : resolve()));
});
}
export async function execute(
conn: snowflake.Connection,
sqlText: string,
binds: snowflake.InsertBinds,
) {
return await new Promise<any[] | undefined>((resolve, reject) => {
conn.execute({
sqlText,
binds,
complete: (error, stmt, rows) => (error ? reject(error) : resolve(rows)),
});
});
}