Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

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}