英文:
How to setup data fixtures in Google App Engine for Go
问题
我想在部署我的Go项目时将一些数据固定放入数据存储中,类似于Django中可以做的那样。这可能吗?如果不行,有没有其他替代方案?
英文:
I would like to have some data fixtures put into data store when my go project is deployed, similar to what can be done in Django. Is it possible? If not, are there any alternatives?
答案1
得分: 1
如果你正在寻找一些将数据放入数据存储的配置,答案是否定的。AppEngine的Python和Java版本也没有这样的功能。
我认为AppEngine的Django框架所做的与你可以做的是一样的。
只需在你的应用程序的init
方法中将所需的数据写入数据存储中,同时在init
方法中检查数据是否已经写入。
然后,每次应用程序启动时,它都会检查是否应该将一些固定数据写入数据存储,并且你可以确保在处理第一个请求之前它已经存在。
英文:
if your are looking for some configuration to put data into datastore, the answer is no. also the python and java versions of appengine don't have such feature.
what i think the django framework for appengine is doing, is the same as you could do.
just write the data you need to the datastore inside your app init
method
also inside init
you check if the data is already written.
then any time the app is startet, he checks if it should write some fixture data to datastore, and you can be sure that before first request is processed that its there.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论