Array query using Go and Datastore

I have the following script:

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

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

What I want to do is request a Band Albumskey for an album with a specific key GenreId.

+4
source share
1 answer

I have found the answer. It turned out to be simple. Instead

Filter("GenreId =", genreId)

I used

Filter("Albums.GenreId =", genreId)

This gave me valid query results.

+4
source

Source: https://habr.com/ru/post/1539778/


All Articles