Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

idea: add a "sliceindex" tag #287

Open
tgirod opened this issue Mar 26, 2021 · 0 comments
Open

idea: add a "sliceindex" tag #287

tgirod opened this issue Mar 26, 2021 · 0 comments

Comments

@tgirod
Copy link

tgirod commented Mar 26, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant