英文:
How to insert multi-value properties on GAE-Datastore in Go?
问题
我找不到关于在Go语言中处理多值属性的方法,在我的情况下,我定义了以下结构体:
type trans struct {
Phone []string `datastore:"phone"`
Name string `datastore:"name,noindex"`
Manager string `datastore:"manager,noindex"`
Mail string `datastore:"email,noindex"`
}
但是我想让Phone
成为多值属性,我不知道该怎么做
我想要的是能够像这样过滤多值属性:
datastore.NewQuery("trans").Filter("phone =", "+33699999999").GetAll(c, &mtrans)
但是这会从数据存储中返回一个空值,就好像没有任何与过滤条件匹配的实体一样。但是确实存在一个具有该电话号码的实体(以及其他实体)。
英文:
I can't find how to work with multiple valued properties on go, in my case I have defined the next struct:
type trans struct {
Phone []string `datastore:"phone"`
Name string `datastore:"name,noindex"`
Manager string `datastore:"manager,noindex"`
Mail string `datastore:"email,noindex"`
}
but I want Phone to be multivalued and I don't know how to do it
What I want to get is to be able to filter on the multivalued property like this:
datastore.NewQuery("trans").Filter("phone =", "+33699999999").GetAll(c, &mtrans)
but this returns a null from the datastore as if it weren't any entity that matches the filter. But there is an entity that has that phone (among others).
答案1
得分: 0
将过滤器更改为"Phone =", ...
。
英文:
Change filter to "Phone =", ...
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论