rethinkdb / rethinkdb-go

Go language driver for RethinkDB

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GetAllByIndex Using An Array As A Key

opened this issue · comments

I've created a secondary index on a table. I can insert items and get them using the web interface and the following code:

r.db("dbname").table("tablename").insert({secondaryindex: ["val1", "val2"]})
r.db("dbname").table("tablename").getAll(["val1","val2"], {index: "secondaryindex"})

However I can't seem to get any results returned when using GetAllByIndex in golang:

key := []string{"val1", "val2"}
res, err := r.Table("tablename").GetAllByIndex("secondaryindex", key).Run(s)
//also tried 
res, err := r.Table("tablename").GetAllByIndex("secondaryindex", r.Args(key)).Run(s)
res, err := r.Table("tablename").GetAllByIndex("secondaryindex", []string{"val1", "val2"}).Run(s)

Calling res.One(&row) returns a "reflect: call of reflect.Value.Type on zero Value" error. I'm not sure if this is a bug or if I'm doing something wrong.

I had a typo in my code around "res.One(&row)" that wasn't passing anything into the res.One function. All the examples above are in fact working as expected.