Sha256: c604bca2d1c65c7d776f8758f896ca76b7b5c42288f49e03a0a11b2e4d4e6a96

Contents?: true

Size: 1.5 KB

Versions: 33

Compression:

Stored size: 1.5 KB

Contents

# Google Cloud Datastore Emulator

To develop and test your application locally, you can use the [Google Cloud
Datastore
Emulator](https://cloud.google.com/datastore/docs/tools/datastore-emulator),
which provides [local
emulation](https://cloud.google.com/sdk/gcloud/reference/beta/emulators/) of the
production Google Cloud Datastore environment. You can start the Google Cloud
Datastore emulator using the `gcloud` command-line tool.

When you run the Cloud Datastore emulator you will see a message similar to the
following printed:

```
If you are using a library that supports the DATASTORE_EMULATOR_HOST
environment variable, run:

  export DATASTORE_EMULATOR_HOST=localhost:8978
```

Now you can connect to the emulator using the `DATASTORE_EMULATOR_HOST`
environment variable:

```ruby
require "google/cloud/datastore"

# Make Datastore use the emulator
ENV["DATASTORE_EMULATOR_HOST"] = "localhost:8978"

datastore = Google::Cloud::Datastore.new project: "emulator-project-id"

task = datastore.entity "Task", "emulatorTask" do |t|
  t["type"] = "Testing"
  t["done"] = false
  t["priority"] = 5
  t["description"] = "Use Datastore Emulator"
end

datastore.save task
```

Or by providing the `emulator_host` argument:

```ruby
require "google/cloud/datastore"

datastore = Google::Cloud::Datastore.new emulator_host: "localhost:8978"

task = datastore.entity "Task", "emulatorTask" do |t|
  t["type"] = "Testing"
  t["done"] = false
  t["priority"] = 5
  t["description"] = "Use Datastore Emulator"
end

datastore.save task
```

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
google-cloud-datastore-2.10.0 EMULATOR.md
google-cloud-datastore-2.9.0 EMULATOR.md
google-cloud-datastore-2.8.0 EMULATOR.md
google-cloud-datastore-2.7.1 EMULATOR.md
google-cloud-datastore-2.7.0 EMULATOR.md
google-cloud-datastore-2.6.0 EMULATOR.md
google-cloud-datastore-2.5.0 EMULATOR.md
google-cloud-datastore-2.4.0 EMULATOR.md
google-cloud-datastore-2.3.1 EMULATOR.md
google-cloud-datastore-2.3.0 EMULATOR.md
google-cloud-datastore-2.2.4 EMULATOR.md
google-cloud-datastore-2.2.3 EMULATOR.md
google-cloud-datastore-2.2.2 EMULATOR.md
google-cloud-datastore-2.2.1 EMULATOR.md
google-cloud-datastore-2.2.0 EMULATOR.md
google-cloud-datastore-2.1.0 EMULATOR.md
google-cloud-datastore-2.0.0 EMULATOR.md
google-cloud-datastore-1.8.2 EMULATOR.md
google-cloud-datastore-1.8.1 EMULATOR.md
google-cloud-datastore-1.8.0 EMULATOR.md