Aymane Mzily
Aymane Mzily

Reputation: 61

Google appengine datastore filter with OR like sql (golang)

I have a struct

type Test struct{
Name      string
Creation  time.Time
User      *datastore.Key
Membres   []*datastore.Key
}

I want equivalent of this sql query in datastore query

SELECT * FROM Test WHERE User=myOwnUser OR myOwnUser in(Membres)

Thank's

Upvotes: 2

Views: 366

Answers (1)

jcjones1515
jcjones1515

Reputation: 481

GQL provides many SQL-like features, but OR isn't one of them (see GQL reference). You could do two queries and a set intersection on the results. Alternatively you could denormalize a bit and add a UserAndMembers property which contained both and then just use an IN query.

Upvotes: 1

Related Questions