// NewUniqueIndex loads a UniqueIndex func NewUniqueIndex(parent *bolt.Bucket, indexName []byte) (*UniqueIndex, error) { var err error b := parent.Bucket(indexName) if b == nil { if !parent.Writable() { return nil, ErrNotFound } b, err = parent.CreateBucket(indexName) if err != nil { return nil, err } } return &UniqueIndex{ IndexBucket: b, Parent: parent, }, nil }
// NewListIndex loads a ListIndex func NewListIndex(parent *bolt.Bucket, indexName []byte) (*ListIndex, error) { var err error b := parent.Bucket(indexName) if b == nil { if !parent.Writable() { return nil, ErrNotFound } b, err = parent.CreateBucket(indexName) if err != nil { return nil, err } } ids, err := NewUniqueIndex(b, []byte("storm__ids")) if err != nil { return nil, err } return &ListIndex{ IndexBucket: b, Parent: parent, IDs: ids, }, nil }