Documentation
¶
Overview ¶
Package schema defines OpenVaultDB schema modes and record validation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateRecord ¶
ValidateRecord validates record data against the collection schema per the database schema mode. col may be nil when no schema is declared for the collection: that is an error in strict mode and a pass otherwise.
Types ¶
type Collection ¶
Collection declares the schema of one collection.
type Field ¶
type Field struct {
Type FieldType `yaml:"type" json:"type"`
Required bool `yaml:"required,omitempty" json:"required,omitempty"`
}
Field declares a single field of a collection schema.
type FieldType ¶
type FieldType string
FieldType is the declared type of a field in a collection schema.
type Mode ¶
type Mode string
Mode is the schema mode of a logical database.
Schemaless means no required pre-declared schema. It does not mean no schema information: partial and schemaless writes are observed into the inferred schema catalogue (see pkg/inferred).
const ( // ModeStrict requires a declared schema for every collection before writes; // writes are validated and unknown fields are rejected. ModeStrict Mode = "strict" // ModePartial validates declared fields; undeclared fields are allowed. ModePartial Mode = "partial" // ModeSchemaless requires no declared schema before writes. ModeSchemaless Mode = "schemaless" )
type Schemas ¶
type Schemas struct {
Collections map[string]Collection `yaml:"collections" json:"collections"`
}
Schemas holds declared collection schemas of a database.
func (*Schemas) Collection ¶
func (s *Schemas) Collection(name string) *Collection
Collection returns the declared schema for the named collection, or nil.
type ValidationError ¶
ValidationError describes a schema-mode validation failure for a write.
func (*ValidationError) Error ¶
func (e *ValidationError) Error() string