I'm unable to add the right tag to the question but I'm using the Storm library (https://github.com/asdine/storm) and I can't seem to get q.In to work, perhaps I'm doing something wrong, or perhaps I've hit a bug in the library, can someone please help? I wanted to post the whole working code but looks like Stackoverfow won't let me anymore, so just posting the offending part.
Editing for more clarity as asked: q.In takes a slice and returns matching objects per the documentation but in my case doesn't return anything and fails with a "not found" error. Doing a db.Select().Find(&a)
instead, works as expected and returns everything without any filtering. Expected output is just one object, the last Foo being saved, the one with the Title=Doler because of the matching tag.
package main
import (
"fmt"
"log"
"github.com/asdine/storm"
"github.com/asdine/storm/q"
)
type Foo struct {
Id int64 `storm:"id,increment"`
Title string `storm:"index"`
Tags []string `storm:"index"`
}
func main() {
if db, e := storm.Open("db/test.db"); e != nil {
log.Fatal("Couldn't open database")
} else {
defer db.Close()
db.Save(&Foo{Title: "Lorem", Tags: []string{"foo", "bar"}})
db.Save(&Foo{Title: "Ipsum", Tags: []string{"foo", "bax"}})
db.Save(&Foo{Title: "Doler", Tags: []string{"quux", "baz"}})
{
var a []Foo
if e := db.Select(q.In("Tags", []string{"quux"})).Find(&a); e != nil {
panic(e) // yikes, doesn't work!
}
}
}
}