storage_options.gno
0.41 Kb ยท 20 lines
1package datastore
2
3// StorageOption configures storages.
4type StorageOption func(*Storage)
5
6// WithSchema assigns a schema to the storage.
7func WithSchema(s *Schema) StorageOption {
8 return func(st *Storage) {
9 if s != nil {
10 st.schema = s
11 }
12 }
13}
14
15// WithIndex assigns an index to the storage.
16func WithIndex(i Index) StorageOption {
17 return func(st *Storage) {
18 st.collection.AddIndex(i.name, i.fn, i.options)
19 }
20}