1package datastore23import "strings"45// StorageOption configures schemas.6type SchemaOption func(*Schema)78// WithField assign a new field to the schema definition.9func WithField(name string) SchemaOption {10 return func(s *Schema) {11 name = strings.TrimSpace(name)12 if name != "" {13 s.fields.Append(name)14 }15 }16}1718// WithDefaultField assign a new field with a default value to the schema definition.19// Default value is assigned to newly created records asociated to to schema.20func WithDefaultField(name string, value interface{}) SchemaOption {21 return func(s *Schema) {22 name = strings.TrimSpace(name)23 if name != "" {24 s.fields.Append(name)2526 key := castIntToKey(s.fields.Len() - 1)27 s.defaults.Set(key, value)28 }29 }30}3132// Strict configures the schema as a strict one.33// By default schemas should allow the creation of any user defined field,34// making them strict limits the allowed record fields to the ones pre-defined35// in the schema. Fields are pre-defined using `WithField`, `WithDefaultField`36// or by calling `Schema.AddField()`.37func Strict() SchemaOption {38 return func(s *Schema) {39 s.strict = true40 }41}42Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.