Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RemoteAPI for Node #1328

Closed
susanlinsfu opened this issue May 18, 2016 · 7 comments
Closed

Implement RemoteAPI for Node #1328

susanlinsfu opened this issue May 18, 2016 · 7 comments
Assignees
Labels
api: datastore Issues related to the Datastore API. type: question Request for information or clarification. Not an issue.

Comments

@susanlinsfu
Copy link

I'd like to be able to connect to the datastore from any NodeJS application including my local. It would be great if the gcloud-node had the RemoteAPI implemented such as python(https://cloud.google.com/appengine/docs/python/tools/remoteapi).

@stephenplusplus
Copy link
Contributor

I might misunderstand, but we support connecting to both the remote API and localhost as well. I know you've been connecting to the emulator, so you already know how to do that. To connect to the remote API, just unset the Datastore emulator environment variable, and make sure to provide a keyFilename with a path to your key file.

@susanlinsfu
Copy link
Author

susanlinsfu commented May 18, 2016

I have my nodejs directory which looks something like this:

MyApp
    -app.js
    -mycredetnials.json
    -package.json
    +node_modules

Inside of my app.js file I have the following code:;

var options = {
    projectId: 'mydatastoreproject'
}

var keyFile = './mydatastoreprojectsandbox-5265e25422c.json';

if (keyFile) {
  options.keyFilename = keyFile;
}

var datastore = gcloud.datastore(options);

I am running this from my local computer. I want my local computer to be able to connect to the Google Cloud Datastore (not the local emulator).

In my developer console I have enabled Google Datastore API. I created a KIND in the developer console and created one entity. I have also created credentials (service account key) in the form of a json file. I then included this json file in my code. By doing this I am still unable to connect to the datastore. Am I missing something or doing something wrong? Essentially all I want to do is to have my local machine connect to the Google Datastore.

@stephenplusplus
Copy link
Contributor

When you start the local datastore and it prints out "Set these environment variables", did you do that? Is that how you've been connecting to your local Datastore so far? By default, gcloud-node tries to talk to the remote API and assumes there is no emulator running. It has to be told to talk to the emulator, which can be done via the env var (DATASTORE_EMULATOR_HOST). If that is what you've been setting, you will have to unset it (or manually do it from the JS script: delete process.env.DATASTORE_EMULATOR_HOST;).

@susanlinsfu
Copy link
Author

ahhhhh yes I had this variable set. All works now thanks!

@stephenplusplus
Copy link
Contributor

No problem, glad that it works now!

@stephenplusplus stephenplusplus added type: question Request for information or clarification. Not an issue. api: datastore Issues related to the Datastore API. labels May 19, 2016
@vinodkumarmarupu
Copy link

how to run on pcf

@Dipesh-Das97
Copy link

How will I be able to use the datastore emulator without the key.json for nodejs?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: datastore Issues related to the Datastore API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants