Google数据存储区模拟器从本地数据库中删除数据 [英] Google Datastore emulator remove data from local database
问题描述
我有一个在本地计算机(Mac OSX 10.11.6)上运行的本地数据存储模拟器实例.
I have a local Datastore emulator instance running on my local machine (Mac OSX 10.11.6).
我已经有很多数据了,但是我想从本地数据库中删除所有数据,以便从头开始.
I have a bunch of data in there already, but I want to remove all data from the local database to start with a clean slate.
但是我已经尝试删除存储数据的目录(我认为是该位置).
However I have already tried deleting the directory (where I thought) the data was being stored.
启动仿真器时出现此消息.
This message appears when starting the emulator.
WARNING: Reusing existing data in [/Users/myusername/.config/gcloud/emulators/datastore].
我删除了整个数据存储目录,并且在重新启动模拟器时似乎已正确重新生成了该目录.但是,旧数据仍然存在.
I deleted the entire datastore directory and it seems to be re-generated properly when the emulator is restarted. However, the old data is still there.
rm -rf /Users/myusername/.config/gcloud/emulators/datastore
我还确认我的Node App正在连接到本地仿真器.
I also confirmed that my Node App is connecting to the local emulator.
myusername$ $(gcloud beta emulators datastore env-init)
myusername$ gcloud beta emulators datastore env-init
export DATASTORE_DATASET=projectname
export DATASTORE_EMULATOR_HOST=localhost:8081
export DATASTORE_EMULATOR_HOST_PATH=localhost:8081/datastore
export DATASTORE_HOST=http://localhost:8081
export DATASTORE_PROJECT_ID=projectname
推荐答案
数据存储区模拟器支持在运行时重置数据存储区.运行测试时,可用于重置数据存储.
Datastore emulator supports resetting datastore when its running. This can be used to reset datastore when running tests.
对 http://localhost:8081/reset
发出 POST
请求,以清除模拟器的内部状态,即
Make POST
request to http://localhost:8081/reset
to clear the internal state of the emulator i.e
curl -X POST http://<emulator-host>:<port>/reset
请参见 https://github.com/GoogleCloudPlatform/google-cloud-java/issues/1292 讨论
这篇关于Google数据存储区模拟器从本地数据库中删除数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!