-
Clone this gist
git clone git@gist.github.com:73675a92b38d2d761016513754543d1c.git datastore-quick cd datastore-quick
-
Install client library:
npm install @google-cloud/datastore
-
Install Google Cloud SDK (
gcloud
) - https://cloud.google.com/sdk/install -
The code can run against real Datastore instance or Datastore mode emulator
a. Datastore mode Emulator
- Install the Emulator -
gcloud components install cloud-datastore-emulator
b. Real Datastore mode Cloud instances
- Enable Firestore API - https://console.cloud.google.com/flows/enableapi?apiid=firestore.googleapis.com
- Go to Datastore console - https://console.cloud.google.com/datastore/welcome - and select Cloud Firestore in Datastore Mode
- Log in locally by running
gcloud auth login
- Install the Emulator -
- If using the Datastore Emulator
- Start the emulator -
gcloud beta emulators datastore start
- Set env variable (in the same terminal where you start the app) -
export DATASTORE_EMULATOR_HOST=localhost:8081
- Start the emulator -
node test.js