schema

package
v0.0.0-...-f810e02 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Diff

type Diff struct {
	Inserted []*PredicateSchema
	Deleted  []*PredicateSchema
	Modified []*ModifiedPredicate
}

Diff represents a changes in 2 schemata

func MakeDiff

func MakeDiff(s1, s2 *Schema) *Diff

MakeDiff creates Diff in 2 schemata

func (*Diff) Empty

func (d *Diff) Empty() bool

Empty returned true if the diff has no insertions, deletions and modifications.

type ModifiedPredicate

type ModifiedPredicate struct {
	From, To *PredicateSchema
}

ModifiedPredicate represents a changes in 2 predicates

type PredicateSchema

type PredicateSchema struct {
	Name       string
	Type       PredicateType
	Tokenizers []string
	Index      bool
	Reverse    bool
	Count      bool
	List       bool
}

PredicateSchema represents predicate schema in Dgraph.

func (*PredicateSchema) String

func (s *PredicateSchema) String() string

type PredicateType

type PredicateType int

PredicateType represents schema types in Dgraph.

const (
	PredicateTypeDefault PredicateType = iota
	PredicateTypeInt
	PredicateTypeFloat
	PredicateTypeString
	PredicateTypeBool
	PredicateTypeDateTime
	PredicateTypeGeo
	PredicateTypePassword
	PredicateTypeUID
)

PredicateType enum values See https://docs.dgraph.io/query-language/#schemav

func PredicateTypeOf

func PredicateTypeOf(name string) (PredicateType, error)

PredicateTypeOf returns PredicateType corresponds to given name

func (PredicateType) String

func (t PredicateType) String() string

type Repository

type Repository interface {
	GetSchema(context.Context) (*Schema, error)
	Update(context.Context, *Diff) error
}

Repository is an interface for operating Dgraph schema.

type Schema

type Schema struct {
	Predicates []*PredicateSchema
}

Schema represents predicate schemata in Dgrpah.

func (*Schema) MarshalText

func (s *Schema) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler

func (*Schema) UnmarshalText

func (s *Schema) UnmarshalText(data []byte) error

UnmarshalText implements encoding.TextUnmarshaler

Jump to

Keyboard shortcuts

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