ddl

package
v0.0.0-...-df05ce4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ColumnDataTypeText      ColumnDataType = "TEXT"
	ColumnDataTypeFloat     ColumnDataType = "FLOAT"
	ColumnDataTypeInteger   ColumnDataType = "INTEGER"
	ColumnDataTypeTimestamp ColumnDataType = "TIMESTAMP"

	ConstraintPrimaryKey ConstraintDataType = "PRIMARY_KEY"
	ConstraintUnique     ConstraintDataType = "UNIQUE"
)

Variables

View Source
var (
	ErrDatabaseDoesNotExists = errors.New("database does not exist")
	ErrDatabaseAlreadyExists = errors.New("database already exists")
)
View Source
var (
	ErrTableDoesNotExists = errors.New("table does not exists")
	ErrTableAlreadyExists = errors.New("table already exists")
)

Functions

func AlterDatabase

func AlterDatabase(rootCollection *gokvstore.Collection, database Database) error

func AlterTable

func AlterTable(rootCollection *gokvstore.Collection, table Table) error

func AreColumnsEqual

func AreColumnsEqual(c1, c2 Column) bool

func AreConstraintsEqual

func AreConstraintsEqual(c1, c2 Constraint) bool

func ColumnIsPrimaryKey

func ColumnIsPrimaryKey(column Column) bool

func CreateDatabase

func CreateDatabase(rootCollection *gokvstore.Collection, database Database, createOrReplace, createIfNotExists bool) error

func CreateTable

func CreateTable(rootCollection *gokvstore.Collection, table Table, createOrReplace, createIfNotExists bool) error

func DatabaseCollection

func DatabaseCollection(rootCollection *gokvstore.Collection, database Database) (*gokvstore.Collection, error)

func DatabaseExists

func DatabaseExists(rootCollection *gokvstore.Collection, database Database) (bool, error)

func DropDatabase

func DropDatabase(rootCollection *gokvstore.Collection, name string) error

func DropTable

func DropTable(rootCollection *gokvstore.Collection, database, name string) error

func TableCollection

func TableCollection(rootCollection *gokvstore.Collection, database, name string) (*gokvstore.Collection, error)

func TableExists

func TableExists(rootCollection *gokvstore.Collection, database, name string) (bool, error)

func ValueHasCorrectTypeForColumn

func ValueHasCorrectTypeForColumn(value any, column Column) bool

Types

type Column

type Column struct {
	Name        string
	DataType    ColumnDataType
	Constraints []Constraint
}

type ColumnDataType

type ColumnDataType string

type Constraint

type Constraint struct {
	Type  ConstraintDataType
	Name  string
	Value string
}

type ConstraintDataType

type ConstraintDataType string

type Database

type Database struct {
	Name   string
	Tables []Table
}

func GetDatabase

func GetDatabase(rootCollection *gokvstore.Collection, databaseName string) (*Database, error)

type Table

type Table struct {
	Name     string
	Database string
	Columns  []Column
}

func GetTable

func GetTable(rootCollection *gokvstore.Collection, database, name string) (*Table, error)

Jump to

Keyboard shortcuts

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