I am trying to run a filter on a property of a nested object for RethinkDB in Golang. But I am sure that I am missing something here.
This is the error I am getting:
(func literal).Eq undefined (type func(gorethink.Term) gorethink.Term has no field or method Eq)
Here is my code:
type User struct {
Id string `json:"id,omitempty"`
FirstName string `json:"firstName,omitempty"`
LastName string `json:"lastName,omitempty"`
Email string `json:"email,omitempty"`
Password string `json:"password,omitempty"`
Salt string `json:"salt,omitempty"`
}
type UnverifiedUserRequest struct {
Id string `json:"id,omitempty"`
Token string `json:"token,omitempty"`
User User `json:"user,omitempty"`
}
db.Table("unverified_requests").Filter(func(row r.Term) r.Term {
return row.Field("user").Map(func(user r.Term) r.Term {
return user.Field("email")
}.Eq(email))
}).Run(session)
UPDATE 1
After making changes as suggested by @icza, the program builds fine. But I am getting the following error at runtime:
gorethink: Cannot convert OBJECT to SEQUENCE in: r.DB("uc_dev").Table("unverified_requests").Filter(func(var_5 r.Term) r.Term { return var_5.Field("user").Map(func(var_6 r.Term) r.Term { return var_6.Field("email") }).Eq("myemail@gmail.com") })