db

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingColumn = errors.New("")

Functions

This section is empty.

Types

type Column

type Column struct {
	Name         string      // the original name of the column in the DB
	Type         string      // the original type of the column in the DB
	Nullable     bool        // true if the column is not NON-NULL
	HasDefault   bool        // true if the column has a default
	IsPrimaryKey bool        // true if the column is a primary key
	Ordinal      int16       // the column's ordinal position
	Comment      string      // the comment attached to the column
	Table        *Table      `json:"-"`
	ForeignKey   *ForeignKey // foreign key database definition
}

Column contains data about a column in a table.

func (Column) Path

func (c Column) Path() string

type Columns

type Columns []*Column

func (Columns) ByOrdinal

func (cc Columns) ByOrdinal() Columns

func (Columns) Filter

func (cc Columns) Filter(filters stringlist.Strings) Columns

Filter applies the regexes specified and filter out all matching schema objects.

func (Columns) Names

func (cc Columns) Names() stringlist.Strings

func (Columns) Paths

func (cc Columns) Paths() stringlist.Strings

func (Columns) Types

func (cc Columns) Types() stringlist.Strings

type DB

type DB map[string]*Schema

func (DB) Filter

func (ss DB) Filter(filters stringlist.Strings) DB

Filter applies the regexes specified and filter out all matching schema objects.

func (DB) GetTable

func (ss DB) GetTable(schema, table string) (*Table, bool)

type Enum

type Enum struct {
	ID      uint32
	Name    string             // the original name of the enum in the DB
	Values  stringlist.Strings // the list of possible values for this enum
	Comment string
	Schema  *Schema `json:"-"`
}

Enum represents a type that has a set of allowed values.

func (Enum) Filter

func (e Enum) Filter(filters stringlist.Strings) Enum

func (Enum) Path

func (e Enum) Path() string

type Enums

type Enums []*Enum

func (Enums) Filter

func (ee Enums) Filter(filters stringlist.Strings) Enums

Filter applies the regexes specified and filter out all matching schema objects.

type ForeignKey

type ForeignKey struct {
	Name           string  // the original name of the foreign key constraint in the db
	Comment        string  // the comment attached to the ForeignKey
	Columns        Columns `json:"-"` // Schema and Table can be retrieved from the source Column
	ForeignColumns Columns `json:"-"` //
}

ForeignKey contains the definition of a foreign key.

func (ForeignKey) ForeignTable

func (f ForeignKey) ForeignTable() *Table

func (ForeignKey) Path

func (f ForeignKey) Path() string

func (ForeignKey) Table

func (f ForeignKey) Table() *Table

type ForeignKeys

type ForeignKeys []*ForeignKey

func (ForeignKeys) Filter

func (ff ForeignKeys) Filter(filters stringlist.Strings) ForeignKeys

Filter applies the regexes specified and filter out all matching schema objects.

type Index

type Index struct {
	Name      string  // name of the index in the database
	IsUnique  bool    // true if the index is unique
	IsPrimary bool    // true if the index is for the PK
	Comment   string  // the comment attached to the index
	Columns   Columns `json:"-"` // list of columns in this index
}

Index contains the definition of an index.

func (Index) Path

func (i Index) Path() string

func (Index) Table

func (i Index) Table() *Table

type Indexes

type Indexes []*Index

func (Indexes) Filter

func (ii Indexes) Filter(filters stringlist.Strings) Indexes

Filter applies the regexes specified and filter out all matching schema objects.

type Param

type Param struct {
	Ordinal       int
	Name          string
	Type          string
	SQLType       string
	QueryPosition int
}

type Params

type Params []*Param

func (Params) ByName

func (pp Params) ByName(name string) *Param

type Schema

type Schema struct {
	Name   string
	Tables Tables
	Enums  Enums
}

Schema holds all the type definitions for a single schema.

func (Schema) Filter

func (s Schema) Filter(filters stringlist.Strings) Schema

func (Schema) GetTable

func (s Schema) GetTable(name string) (*Table, bool)

type Table

type Table struct {
	ID          uint32
	Name        string      // the original name of the table in the DB
	Type        string      // the table type (e.g. VIEW or BASE TABLE)
	Comment     string      // the comment attached to the table
	Schema      *Schema     // reference to schema `json:"-"`
	Columns     Columns     // ordered list of columns in this table
	ReadOnly    bool        // table allows insert/update/delete
	Indexes     Indexes     // list of indexes in this table
	ForeignKeys ForeignKeys // list of Foreign Keys from the table
	References  ForeignKeys // list of Foreign Keys to the table

	PrimaryKeys Columns // list of columns that are flagged as Primary Keys
}

Table contains the definition of a table.

func (Table) Filter

func (t Table) Filter(filters stringlist.Strings) Table

func (Table) GetColumnByName

func (t Table) GetColumnByName(name string) *Column

func (Table) GetColumnsByName

func (t Table) GetColumnsByName(names []string) ([]*Column, error)

func (Table) GetPK

func (t Table) GetPK() *Column

func (Table) HasPrimaryKey

func (t Table) HasPrimaryKey() bool

func (Table) Path

func (t Table) Path() string

type Tables

type Tables []*Table

func (Tables) Filter

func (tt Tables) Filter(filters stringlist.Strings) Tables

Filter applies the regexes specified and filter out all matching schema objects.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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