From e31f75cb63341cb7b997d21ea9da8c406bf4de64 Mon Sep 17 00:00:00 2001 From: Brian Buller Date: Wed, 11 Dec 2024 16:48:05 -0600 Subject: [PATCH] Add non-bucket StringListContains --- boltease.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/boltease.go b/boltease.go index 38b657a..670e801 100644 --- a/boltease.go +++ b/boltease.go @@ -660,6 +660,19 @@ func (b *DB) AddToStringList(path []string, values ...string) error { return err } +func (b *DB) StringListContains(path []string, value string) (bool, error) { + list, err := b.GetStringList(path) + if err != nil { + return false, err + } + for i := range list { + if list[i] == value { + return true, nil + } + } + return false, nil +} + // GetKeyValueMap returns a map of all key/value pairs in the bucket at path func (b *DB) GetKeyValueMap(path []string) (map[string][]byte, error) { var err error