我是Google App Engine的新手,遇到了数据存储的一些问题.
我写了一个测试GaeDatastore_test.go来测试datastore.Query.GetAll方法,见下文
package persist
import (
"fmt"
"testing"
"appengine/aetest"
"appengine/datastore"
)
type Mock struct {
Name string
}
func TestAll(t *testing.T) {
ctx, _ := aetest.NewContext(nil)
defer ctx.Close()
d := &Mock{
"hello",
}
fmt.Println(datastore.Put(ctx, datastore.NewIncompleteKey(ctx, "test", nil), d))
fmt.Println(datastore.Put(ctx, datastore.NewIncompleteKey(ctx, "test", nil), d))
fmt.Println(datastore.Put(ctx, datastore.NewIncompleteKey(ctx, "test", nil), d))
q := datastore.NewQuery("test")
var ms []Mock
q.GetAll(ctx, &ms)
fmt.Printf("%#v", ms)
}
Run Code Online (Sandbox Code Playgroud)
当我使用运行测试文件时
goapp测试
它不会返回我存储的3个实体.我可以在调用datastore.Put后看到键返回,我可以使用datastore.Get使用键检索它们.但'ms'总是为零.
然后我尝试使用初始化ms
使([]素,10)
但它没有太大的区别,数据仍未通过.
我检查了query.go源文件.在内部,它使用loadEntity,这与Get/GetMulti使用的方法相同,并使用append将元素推送到切片.ms是零,这很奇怪.
客户端连接到模拟GAE环境的Python服务器.有人可以帮忙吗?
我最近搞了GAE,发现它错过了基础!=(不等于)过滤器在他们的数据存储API中.
https://developers.google.com/appengine/docs/go/datastore/queries#Go_Property_filters
它也没有"OR"条件操作数.
任何人都可以告诉我如何过滤不相等的数据?