Documentation
¶
Index ¶
- Constants
- Variables
- func GetSchemaVersion(schema cue.Value) (string, error)
- func GetV1Model(schema cue.Value) (string, error)
- type Database
- func (d *Database) GetTable(name string) (Table, error)
- func (d *Database) GetTables() map[string]Table
- func (d *Database) Insert(table Table, record map[string]interface{}) error
- func (d *Database) MarshalJSON() ([]byte, error)
- func (d *Database) ReferentialIntegrity() error
- func (d *Database) RegisterTables(cueString string) error
- type SchemaV1Metadata
- type Table
Constants ¶
const SCHEMA_V1_METADATA = `
{
_schema: {
namespace: string
name: string
}
}
`
SCHEMA_V1_METADATA is the cue representation of SchemaV1Metadata
const V1_MODEL = `
{
_model: {
plural: string
}
}
`
V1_MODEL is the cue representation of Model metadata
Variables ¶
var GET_VERSION_CUE = `
{
_schema: {
version: string
}
}
`
GET_VERSION_CUE is a constant? that is added to cue models
Functions ¶
func GetSchemaVersion ¶
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 ¶
NewDatabase creates a "world" struct to store records
func (*Database) MarshalJSON ¶
MarshalJSON returns the database encoded in JSON format
func (*Database) ReferentialIntegrity ¶
ReferentialIntegrity checks the relationships between the records in the content database
func (*Database) RegisterTables ¶
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 SchemaV1Metadata ¶
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