SAP / node-hdb

SAP HANA Database Client for Node
Apache License 2.0
317 stars 98 forks source link

Async / Await #122

Open stefanhipfel opened 6 years ago

stefanhipfel commented 6 years ago

Hi,

it would be great to be able to use async/await with this library. In the meantime I have promisified all functions myself. It would be great if the lib itself would always return a promise instead of a callback.

Thanks!

alexpenev-s commented 6 years ago

Hi, That's a good idea. At the moment we do not plan to add new features to hdb. New development is going into the hana-client driver

stefanhipfel commented 6 years ago

Hi,

ah good to know, thank you!

alexpenev-s commented 6 years ago

Hi, Here is how to install it: npm config set @sap:registry https://npm.sap.com npm install @sap/hana-client

Documentation: https://help.sap.com/viewer/0eec0d68141541d1b07893a39944924e/2.0.02/en-US/58c18548dab04a438a0f9c44be82b6cd.html

I updated the Readme with this info as well.

stefanhipfel commented 6 years ago

So makes sense to implement promises in this new lib :)

Is there any document on how to use this new client with hdi? Thanks!

alexpenev-s commented 6 years ago

At the moment hdi will continue to work with hdb. In the future it should change to the new hana-client. Best regards

stefanhipfel commented 6 years ago

Where can I find the git project for the new client? So we can link this feature request there. Thanks

alexpenev-s commented 6 years ago

There isn't a git project at the moment. For internal or external clients. BCP for internal / SAP Community for external - https://answers.sap.com/index.html

s-pic commented 5 years ago

I made good experiences util.promisifying methods provided by hdb, like so:

function getExecutePromise(statement) {
    return util.promisify(statement.execute.bind(statement));
}

const prepareCallAsync = util.promisify(this.connection.prepare.bind(this.connection));

const statement = await prepareCallAsync(sqlString);
const executePromise = this.getExecutePromise(statement);
await executePromise(paramsObj);
larshp commented 2 years ago

see https://www.npmjs.com/package/sap-hdb-promisfied