Last active
May 26, 2021 14:36
-
-
Save jasper07/0c286f90d14ce995c31c06044d7c1ea3 to your computer and use it in GitHub Desktop.
SAP HANA Database Client for Node working with ES6 Async Await
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var util = require('util'); | |
var client = require('./client'); | |
var fields = ['SCHEMA_NAME || \'.\' || TABLE_NAME as TABLE']; | |
var sql = util.format('select top 5 %s from TABLES', fields.join(',')); | |
const connect = async () => | |
await client.connect(); | |
const executeAndfetchRows = async () => | |
new Promise((resolve, reject) => | |
client.exec(sql, (err, rows) => resolve(rows))); | |
const disconnect = async (rows) => { | |
await client.disconnect(); | |
return rows; | |
} | |
const done = (rows) => { | |
console.log(util.inspect(rows, { | |
colors: true | |
})) | |
} | |
connect() | |
.then(executeAndfetchRows) | |
.then(disconnect) | |
.then(done); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
./client
is it a file?