How to insert multi-value properties on GAE-Datastore in Go?

huangapple go评论71阅读模式
英文:

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成为多值属性,我不知道该怎么做 How to insert multi-value properties on GAE-Datastore in Go?

我想要的是能够像这样过滤多值属性:

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 How to insert multi-value properties on GAE-Datastore in Go?

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 =", ...

huangapple
  • 本文由 发表于 2014年5月20日 17:31:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/23755985.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定