schema

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckLock

func CheckLock(s *Schema, lockPath string) error

CheckLock verifies the schema against a lock file. If the lock file does not exist, it creates one. If it exists, it verifies that nothing was removed (append-only).

func SortedPropertyNames

func SortedPropertyNames(props map[string]Property) []string

SortedPropertyNames returns property names in sorted order for a given map.

func WriteLock

func WriteLock(s *Schema, lockPath string) error

WriteLock writes the current schema state to a lock file.

Types

type EdgeType

type EdgeType struct {
	Name       string              `json:"-"`
	From       string              `json:"from"`
	To         string              `json:"to"`
	Properties map[string]Property `json:"-"`
}

EdgeType defines an edge type in the schema.

type NodeType

type NodeType struct {
	Name       string              `json:"-"`
	Properties map[string]Property `json:"-"`
}

NodeType defines a node type in the schema.

type PropType

type PropType string

PropType represents the type of a property.

const (
	PropTypeString PropType = "string"
	PropTypeInt    PropType = "int"
	PropTypeFloat  PropType = "float"
	PropTypeBool   PropType = "bool"
)

type Property

type Property struct {
	Name     string   `json:"-"`
	Type     PropType `json:"type"`
	Required bool     `json:"required,omitempty"`
}

Property defines a single property on a node or edge type.

type Schema

type Schema struct {
	Nodes map[string]*NodeType `json:"-"`
	Edges map[string]*EdgeType `json:"-"`
}

Schema is the top-level schema definition.

func Load

func Load(path string) (*Schema, error)

Load reads and parses a schema JSON file.

func Parse

func Parse(data []byte) (*Schema, error)

Parse parses schema JSON bytes into a Schema.

func (*Schema) EdgeTypeID

func (s *Schema) EdgeTypeID(name string) (uint16, bool)

EdgeTypeID returns the uint16 ID for an edge type.

func (*Schema) LabelID

func (s *Schema) LabelID(name string) (uint16, bool)

LabelID returns the uint16 ID for a node label.

func (*Schema) SortedEdgeNames

func (s *Schema) SortedEdgeNames() []string

SortedEdgeNames returns edge type names in sorted order for deterministic output.

func (*Schema) SortedNodeNames

func (s *Schema) SortedNodeNames() []string

SortedNodeNames returns node type names in sorted order for deterministic output.

func (*Schema) Validate

func (s *Schema) Validate() error

Validate checks the schema for internal consistency.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL