使用Go和Datastore查询阵列

时间:2014-05-08 14:30:59

标签: google-app-engine go google-cloud-datastore

我有以下情况:

type Band struct {
    Name       string
    LocationId *datastore.Key
    Albums     []Album
}

type Album struct {
    Name    string
    GenreId *datastore.Key
    Year    int
}

我想要查询Band的{​​{1}}密钥,查找具有特定Albums密钥的相册。

1 个答案:

答案 0 :(得分:4)

我找到了答案。事实证明这很简单。而不是

Filter("GenreId =", genreId)

我用过

Filter("Albums.GenreId =", genreId)

这给了我有效的查询结果。