Skip to content

idea: add a "sliceindex" tag #287

Open

Description

@tgirod

As it is, one can add a index tag to a slice field, and the whole slice will be used as a key in the index - which is expected, but not very useful. It would be nice to have a sliceindex tag which build an index where each value of the slice is inserted in the index.

type Post struct {
    ID int `storm:"increment"`
    Tags []string{} `storm:"sliceindex"`
    Text string
}

// db contains several entries with various tags ...

// returns posts which contain the tag "foo"
var foo []Post
db.Find("Tags", "foo", &foo)

// returns posts which contain the tags "foo" and "bar"
var fooBar []Post
db.Find("Tags", []string{"foo", "bar"})

Well, I guess it is already possible to do just that with a separate bucket associating Tags and post IDs, but I think this would make what I see as a very common use case much easier to do.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions