mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 20:54:07 -08:00
28 lines
726 B
TypeScript
28 lines
726 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, _, rows) => (error ? reject(error) : resolve(rows)),
|
|
});
|
|
});
|
|
}
|