I'm trying to do some exercises, like this one: https://blogs.sap.com/2016/03/28/developing-with-xs-advanced-add-business-logic-with-nodejs/
In that exercise, there is this code snippet:
function saveCountry(country){
var conn = $.hdb.getConnetion();
var output = ...
}
And no matter what, I got this error :
500 Cannot read property 'getConnection' of undefined
Additionally, I tried to make a Node.js from terminal, using vim, node and xs as in this documentation: https://help.sap.com/viewer/4505d0bdaf4948449b7f7379d24d0f0d/2.0.02/en-US/32392948cb1844b2a6ed22ad641d4461.html
In item 3 of that documentation there's this code snippet:
var express = require('express');
var app = express();
var xsenv = require('@sap/xsenv');
var services = xsenv.getServices({ hana:'myhana' });
// also tried this ways:
// xsenv.getServices({hana: {tag:'myhana'}});
// xsenv.getServices({hana: {tag:'hana'}});
app.get('/', function (req, res) {
res.send('Using HANA ' + services.hana.host + ':' + services.hana.port);
});
var port = process.env.PORT || 3000;
app.listen(port, function () {
console.log('myapp listening on port ' + port);
});
Now, create a service:
xs create-service hana hdi-shared myhana
And also, verify that service exists:
xs s
Then, run the nodejs-app
with :
xs push
And result error:
No service matches hana
So, in resume, what am I missing in order to use $.hdb.getConnetion();
?
When I created the project from webIDE I clicked option enable xsjs
, that's so, that I have this var xsjs = require('@sap/xsjs');
And, in the other exercise, how is that "no service matches" and I clearly see it!
This is the version installed and box specs:
HDB version info:
version: 2.00.030.00.1522210459
branch: hanaws
machine config: linuxx86_64
git hash: bb2ff6b25b8eab5ab382c170a43dc95ae6ce298f
git merge time: 2018-03-28 06:14:19
weekstone: 2018.13.0
cloud edition: 0000.00.00
compile date: 2018-03-28 06:19:13
compile host: ld2221
compile type: rel
RedHat 7.5
Thanks a lot for all help.
xOCh