gizzmodb

package
v0.0.0-...-750f124 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotCreated = fmt.Errorf("no such")
View Source
var SchemaGame = &Schema{
	Version: model.Version{
		Major:     0,
		Minor:     1,
		Patch:     0,
		Extension: 0,
		Created:   time.Now(),
		Updated:   time.Now(),
	},

	Create: []string{

		`CREATE TABLE version (
item BIGINT, itemn BIGINT,			
major SMALLINT,
minor SMALLINT,
patch SMALLINT,
extension SMALLINT,
PRIMARY KEY (item,itemn,major,minor));`,

		`CREATE TABLE items (
class VARCHAR(80) NOT NULL,
classn INTEGER,
content TEXT,
major BIGINT, minor BIGINT,			
origin BIGINT, originn BIGINT,
created TIMESTAMP, updated TIMESTAMP,
encoding SMALLINT,
PRIMARY KEY (major,minor));`,

		"CREATE INDEX items_class ON items (class,classn,origin,originn);",
		"CREATE INDEX items_classn ON items (classn,class,origin,originn);",
		"CREATE INDEX items_origin_t ON items (origin,originn,class,classn);",
		"CREATE INDEX items_origin_c ON items (origin,originn,classn,class);",

		`CREATE TABLE tags (
name VARCHAR(32) NOT NULL,
weight DOUBLE PRECISION,
major BIGINT, minor BIGINT,
PRIMARY KEY (name,major,minor));`,

		"CREATE INDEX tags_id ON tags (major,minor,weight);",
		"CREATE INDEX tags_name ON tags (name,weight,major,minor);",

		`CREATE TABLE links (
major BIGINT, minor BIGINT,
linked BIGINT, linkedn BIGINT,
repeated SMALLINT, weight DOUBLE PRECISION,
PRIMARY KEY (major,minor,linked,linkedn));`,

		"CREATE INDEX links_weight ON links (major,minor,weight);",
		"CREATE INDEX links_weight_link ON links (linked,linkedn,weight);",
	},

	InsertVersion: `INSERT INTO version (item, itemn, major, minor, patch, extension) 
VALUES (:item,:itemn,:major,:minor,:patch,:extension);`,

	InsertItem: `INSERT INTO items (class, classn, content, encoding, major, minor, origin, originn, created, updated)
VALUES (:class,:classn,:content,:encoding,:major,:minor,:origin,:originn,:created,:updated);`,

	InsertLink: `INSERT INTO links (major, minor, linked, linkedn, repeated, weight)
VALUES (:major,:minor,:linked,:linkedn,:repeated,:weight);`,

	InsertTag: `INSERT INTO tags (name, weight, major, minor)
VALUES (:name,:weight,:major,:minor);`,

	GetVersion: `SELECT * FROM version WHERE item=$1 AND itemn=$2 AND major=$3 AND minor=$4;`,

	GetVersions: `SELECT item FROM version;`,

	GetItem: `SELECT * FROM items WHERE major=$1 AND minor=$2;`,

	GetLinks: `SELECT * FROM links WHERE major=$1 AND minor=$2;`,

	GetLink: `SELECT * FROM links WHERE major=$1 AND minor=$2 AND linked=$3 AND linkedn=$4;`,
}

Functions

This section is empty.

Types

type Data

type Data struct {
	Schema *Schema
	Keys   *access.DataKeys

	Err error
	// contains filtered or unexported fields
}

func NewGameData

func NewGameData(driver, path string) *Data

func (*Data) Close

func (data *Data) Close()

func (*Data) Create

func (data *Data) Create(game *model.Record, version *model.Version)

func (*Data) GetRecord

func (data *Data) GetRecord(record *model.Record)

func (*Data) GetVersion

func (data *Data) GetVersion(version *model.Version) *model.Version

func (*Data) GetVersions

func (data *Data) GetVersions() error

func (*Data) HasError

func (data *Data) HasError(err error) bool

func (*Data) HasErrors

func (data *Data) HasErrors() bool

func (*Data) InsertItems

func (data *Data) InsertItems(items ...model.Recorder)
func (data *Data) InsertLinks(links ...*model.Link)
func (data *Data) LoadLinks(record *model.Record) (records []*model.Record)

func (*Data) Save

func (data *Data) Save(rec model.Recorder)

type Schema

type Schema struct {
	Version model.Version
	Create  []string

	InsertVersion string
	InsertItem    string
	InsertLink    string
	InsertTag     string

	GetVersions string
	GetVersion  string
	GetItem     string
	GetLink     string
	GetLinks    string
}

func NewSchema

func NewSchema() *Schema

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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