I am trying to connect to the Google Cloud Datastore using node.js and the data layer functionality present in the Seneca framework. The Seneca framework needs to create a connection to a database as per connecting to a database instance, passing information like:
name: '',
host: '',
port: ,
username: '',
password: ''
etc.
Is there a way to connect to a Google Datastore like a typcal database instance or is the only way through REST api calls?
Authentication support for Google Cloud Datastore is currently limited to OAuth 2.0. See Getting started with Google Cloud Datastore and Node.js.
The credentials are passed along in each HTTP request.
At the moment, the only way to connect to the Google Cloud Datastore, using node.js, is by using the REST API.
Using the google-api-nodejs-client you can get access to a datastore object:
googleapis.discover('datastore', 'v1beta2')
.withAuthClient(authCredentials)
.execute(function(err, client) {
if (err) {
seneca.log.error(err);
}
datastore = client.datastore.withDefaultParams({
datasetId: datasetid}).datasets;
});
This object will be like your connection object and you can use this object to make queries to your datastore.