B4J Question BANano node.js libraries

walterf25

Expert
Licensed User
Hi all, can node.js libraries be used with BANano, if so does anyone have a small examples on how to use them.

More specifically i am interested in using the google cloud Datastore node javascript library, I was able to successfuly use the java version with ABMaterial but I now have the need to use it using BANano.

here's a small part of the code i would like to port
JavaScript:
const {Datastore} = require('@google-cloud/datastore');
const projectId = 'abcdefghi';
const ds = new Datastore({
  projectId: projectId,
});
const keyName = 'UNSPLASH_KEY';
const kind = 'Strings';
const stringKey = ds.key([kind, keyName]);

var appkey = 'not set';

var entity  = {
key: stringKey,
value: appkey,
};

entity = ds.get(stringKey);

I am slowly getting familiar with BANano and I think is a great addition to this community and would really help me out a great deal if I could figure out how to use this google cloud datastore node.js libary.

The library can be found here.

In advance thanks everyone, hopefully someone can point me in the right direction.

Walter
 

Mashiane

Expert
Licensed User
It looks like this has a REST API which is excellent alternative. You can then use BANananoFetch to execute stuff for your endpoints.


As far as I know one cannot use nodejs directly. However if there is a "module" then you can load it as a BANanoPromise and then execute scripts using it. This however has to be a compiled JS file.

From what I've noted, there is no "dist" file after installing the @google-cloud, these are the only folders available.

1615624485395.png


Perhaps Alain can shed some more light on what could be the best approach. #My2Cents
 
Upvote 0
Top