n8n/packages/nodes-base/nodes/Snowflake/GenericFunctions.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

28 lines
729 B
TypeScript
Raw Normal View History

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