cuedb

package
v0.2.1 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
View Source
var GET_VERSION_CUE = `
{
	_schema: {
		version: string
	}
}
`

GET_VERSION_CUE is a constant? that is added to cue models

Functions

func GetSchemaVersion

func GetSchemaVersion(schema cue.Value) (string, error)

GetSchemaVersion will attempt to pull a "version" out of the schema's metadata, returning an error if it can't

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 added in v0.2.1

func (d *Database) DumpAll()

func (*Database) GetConfigString added in v0.2.1

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 added in v0.2.1

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 added in v0.2.1

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 added in v0.2.1

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

type ModelV1Metadata added in v0.2.1

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) 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) GetSupportedExtensions added in v0.2.1

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

func (*Table) ID

func (t *Table) ID() string

ID returns the table's name

func (*Table) IsSupportedExtension added in v0.2.1

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