UNPKG

sqmicro-connection

Version:

Connection abstraction for SQ Micro.

35 lines (26 loc) 948 B
// start as // LOG_LEVEL=trace node ./test-connection.js const Driver = require('./fake-driver'); const Connection = require('../')(Driver); const c = new Connection({ connectionString: 'http://user:pass@google.com/something', stableNetwork: true }); c.on('error', e => console.error(`E: ${e}`)); c.on('disconnected', () => console.log('X: disconnected')); c.on('connected', () => console.log('X: connected')); c.on('end', () => console.log('Bye-bye, user!')); c.connect().then( () => work(), (e) => console.error(`Something went wrong: ${e}`) ); async function work() { const rows = new Set(); rows.add({ a: 11, b: 12 }); rows.add({ a: 21, c: 23 }); rows.add({ b: 32, c: 33 }); const res = await c.copy('Destination', rows, { fieldNames: 'a b c'.split(' '), delimiter: ';' }); console.log(`Finished with '${res}'`); c.disconnect(); } process.on('unhandledRejection', console.error);