App Engine: How to “reset” the datastore?

2019-03-09 01:21发布

Well, I'm developing in App Engine (Java) and after a lot of tries and deployments, I need to reset the datastore. There is a lot of random data I added to test performance, and besides that the entities changed a lot, so I need to delete all: data, tables, indexes.

How can I do that?

15条回答
不美不萌又怎样
2楼-- · 2019-03-09 01:58

in my case (working with eclipse plugin and play framework) I had to stop the application, delete file /apps/crud-gae/tmp/datastore and then restart the app

it worked for me... working locally, of course...

查看更多
趁早两清
3楼-- · 2019-03-09 01:59

According to GAE docs you can delete multiple objects in JDO, call the PersistenceManager's deletePersistentAll(...) method with a Collection of objects.

PersistenceManager pm = PMF.get().getPersistenceManager();

Query query = pm.newQuery("select from " + Your.class);

List<Your> objs = (List<Your>) query.execute();

pm.deletePersistentAll(objs);
查看更多
相关推荐>>
4楼-- · 2019-03-09 02:01

Out of context for java dev but since there's few documentation here's how to do it in go :

keys, _ := datastore.NewQuery("").KeysOnly().GetAll(c, nil)
datastore.DeleteMulti(c, keys)
查看更多
登录 后发表回答