git clone https://github.com/shwetasrivastava/node.js-hana-client.git
npm start
Mention the connection params in configs => dbConnection.js
Add the respective value in .env file.
connection call to HDB using @sap/hana-client in app.js
const connection = hanaClient.createConnection(); connection.connect(connectionParams, (err) => { if(err){ console.error("Connection error",err); } else{ console.log("connection to DB established successfully"); }
});
use the connection object anywhere within the project to fetch the result set from the required table.
global.connection = connection;
check services ==> dbService.js
Function to execute the SQL has been mentioned there.
To execute a simple SQL statement bind your call to
dbService.execute(query);
To execute the batch operations use
dbService.executeBatch(query,data);
For transaction enablement use commit, rollback and setAutocommit functions defined already.
For more details please visit to offical @sap/hana-client page:-
If you want to use an ORM for node with hana use the below npm package https://www.npmjs.com/package/ohana-node-orm