英文:
My datastore has no index entries on appspot?
问题
首先,我创建了一个 index.yaml 文件:
-
kind: Tarifa 2014
ancestor: yes
properties:- name: Date
direction: desc
- name: Date
-
kind: Tarifa 2014
ancestor: yes
properties:- name: Division
- name: Heat
- name: Date
direction: desc
然后,我放入了一些数据:
key := datastore.NewKey(s.Context, "Tarifa 2014", "", 0, s.Root)
key, err = datastore.Put(s.Context, key, m)
简单的查询可以正常工作:
key := datastore.NewKey(s.Context, "Tarifa 2014", "", id, s.Root)
err = datastore.Get(s.Context, key, &m)
但是这个查询不起作用,因为我的索引仍然是空的:
datastore.NewQuery(e).Ancestor(s.Root).Filter("Division =", d).Filter("Heat =", h).Order("-Date")
同样,这个查询也不起作用:
datastore.NewQuery(e).Ancestor(s.Root).Order("-Date")
我的索引在 appspot.com 上是这样的:
我的 datastore 在 appspot.com 上是这样的:
请注意,在 localhost:8080 上所有的查询都正常工作。
英文:
First I create a index.yaml
- kind: Tarifa 2014
ancestor: yes
properties:
- name: Date
direction: desc
- kind: Tarifa 2014
ancestor: yes
properties:
- name: Division
- name: Heat
- name: Date
direction: desc
Then I put some data in
key := datastore.NewKey(s.Context, "Tarifa 2014", "", 0, s.Root)
key, err = datastore.Put(s.Context, key, m)
Simple queries work,
key := datastore.NewKey(s.Context, "Tarifa 2014", "", id, s.Root)
err = datastore.Get(s.Context, key, &m)
but this does do not because my index is still empty?
datastore.NewQuery(e).Ancestor(s.Root).Filter("Division =", d).Filter("Heat =", h).Order("-Date")
Same for this, it also does not work?
datastore.NewQuery(e).Ancestor(s.Root).Order("-Date")
My index looks like this on appspot.com?
My datastore looks like this on appspot.com
Note that on localhost:8080 all queries work fine?
答案1
得分: 0
由于原因不明,如果我使用Namespace
,在appspot.com上索引查询会出错。
c2 := endpoints.NewContext(r)
c, err := appengine.Namespace(c2, "")
if err != nil {return err}
你需要直接使用没有命名空间的端点上下文。
c := endpoints.NewContext(r)
英文:
For a reason that is not clear, if I use Namespace
, indexed queries break on appspot.com
c2 := endpoints.NewContext(r)
c, err := appengine.Namespace(c2, "")
if err != nil {return err}
You need to use endpoints context directly without a namespace.
c := endpoints.NewContext(r)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论