cuedb

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ModelV1MetadataCue = `
{
	_model: {
		plural: string
		supportedExtensions: [...string]
	}
}
`
View Source
const SchemaV1MetadataCue = `
{
	_schema: {
		namespace: string
		name: string
	}
}
`

SchemaV1MetadataCue is the cue representation of SchemaV1Metadata

Variables

View Source
var BaseConfig string

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database is the "world" struct. We can "insert" records into it and know immediately if they're valid or not.

func NewDatabase

func NewDatabase() (Database, error)

NewDatabase creates a "world" struct to store records

func (*Database) DumpAll

func (d *Database) DumpAll()

func (*Database) GetConfigString

func (d *Database) GetConfigString(key string) (string, error)

func (*Database) GetTable

func (d *Database) GetTable(name string) (Table, error)

GetTable returns a single table in the database

func (*Database) GetTableDataDir

func (d *Database) GetTableDataDir(table Table) string

func (*Database) GetTables

func (d *Database) GetTables() map[string]Table

GetTables returns the tables in the Database

func (*Database) Insert

func (d *Database) Insert(table Table, record map[string]interface{}) error

Insert adds a record

func (*Database) LoadConfig

func (d *Database) LoadConfig() error

func (*Database) MarshalJSON

func (d *Database) MarshalJSON() ([]byte, error)

MarshalJSON returns the database encoded in JSON format

func (*Database) ReferentialIntegrity

func (d *Database) ReferentialIntegrity() error

ReferentialIntegrity checks the relationships between the records in the content database

func (*Database) RegisterTables

func (d *Database) RegisterTables(cueString string) error

RegisterTables ensures that the cueString schema is a valid schema and parses the Cue to find Models within. Each Model is registered as a Table, provided the name is available.

type Model

type Model struct {
	// contains filtered or unexported fields
}

type ModelV1Metadata

type ModelV1Metadata struct {
	Plural              string
	SupportedExtensions []string
}

V1_MODEL is the cue representation of Model metadata

func GetV1Model

func GetV1Model(schema cue.Value) (ModelV1Metadata, error)

GetV1Model returns the V1_MODEL information from a cue.Value

type SchemaV1Metadata

type SchemaV1Metadata struct {
	Namespace string
	Name      string
}

SchemaV1Metadata stores information about the schema that is shared

func GetSchemaV1Metadata

func GetSchemaV1Metadata(schema cue.Value) (SchemaV1Metadata, error)

GetSchemaV1Metadata returns the metadata for a cue.Value

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table represents a schema record

func (*Table) CueDataPath

func (t *Table) CueDataPath() cue.Path

func (*Table) CuePath

func (t *Table) CuePath() cue.Path

CuePath returns the plural form of the table's name

func (*Table) Directory

func (t *Table) Directory() string

Directory returns the plural form of the table name

func (*Table) GetDefPath

func (t *Table) GetDefPath() cue.Path

func (*Table) GetSupportedExtensions

func (t *Table) GetSupportedExtensions() []string

func (*Table) ID

func (t *Table) ID() string

ID returns the table's name

func (*Table) InlinePath

func (t *Table) InlinePath() string

func (*Table) IsSupportedExtension

func (t *Table) IsSupportedExtension(ext string) bool

Jump to

Keyboard shortcuts

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