schema

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Boolean

type Boolean struct{}

Boolean type

func (*Boolean) String

func (*Boolean) String() string

type Bytes added in v0.0.6

type Bytes struct{}

func (*Bytes) String added in v0.0.6

func (*Bytes) String() string

type Column

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

Column struct

func NewColumn

func NewColumn(
	name string,
	alias string,
	dataType DataType,
	notNull bool,
	comment *string,
	defaultValue *string,
	isPrimaryKey bool,
) *Column

NewColumn fn

func (*Column) Camel

func (c *Column) Camel() string

Camel case

func (*Column) JSONKey

func (c *Column) JSONKey() string

JSONKey fn

func (*Column) Name

func (c *Column) Name() string

Name of the column

func (*Column) Nullable

func (c *Column) Nullable() bool

Nullable of column

func (*Column) Pascal

func (c *Column) Pascal() string

Pascal case

func (*Column) SQLName

func (c *Column) SQLName() string

SQLName fn

func (*Column) Type

func (c *Column) Type() string

Type of column

type DataType

type DataType interface {
	String() string
}

DataType for a column

type DateTime

type DateTime struct{}

DateTime type

func (*DateTime) String

func (*DateTime) String() string

type Enum

type Enum struct {
	Name   string
	Values []*EnumValue
}

Enum struct

func (*Enum) Camel

func (e *Enum) Camel() string

Camel generates the camel case

func (*Enum) Pascal

func (e *Enum) Pascal() string

Pascal generates the pascal case

func (*Enum) Slug

func (e *Enum) Slug() string

Slug generates the slug case

type EnumValue

type EnumValue struct {
	Label string
	Order int
}

EnumValue is an enum value

func (*EnumValue) Pascal

func (v *EnumValue) Pascal() string

Pascal case

type Enumerable

type Enumerable struct {
	Schema string
	Name   string
}

Enumerable type

func (*Enumerable) String

func (e *Enumerable) String() string

type Filter

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

Filter struct

func (*Filter) Fields

func (f *Filter) Fields() (fields []*FilterField, err error)

Fields gets the filter fields based on the type

type FilterField

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

FilterField struct

func (*FilterField) Camel

func (f *FilterField) Camel() string

Camel case

func (*FilterField) Coerce

func (f *FilterField) Coerce(value string) (string, error)

Coerce the value of the filter field

func (*FilterField) Description

func (f *FilterField) Description() string

Description of the field

func (*FilterField) Format

func (f *FilterField) Format() string

Format fn

func (*FilterField) Name

func (f *FilterField) Name() string

Name fn

func (*FilterField) NullFormat

func (f *FilterField) NullFormat() string

NullFormat fn

func (*FilterField) Nullable

func (f *FilterField) Nullable() bool

Nullable fn

func (*FilterField) Pascal

func (f *FilterField) Pascal() string

Pascal case

func (*FilterField) Spread

func (f *FilterField) Spread() string

Spread fn

func (*FilterField) Type

func (f *FilterField) Type() string

Type of filter

type Float32

type Float32 struct{}

Float32 type

func (*Float32) String

func (*Float32) String() string

type Float64

type Float64 struct{}

Float64 type

func (*Float64) String

func (*Float64) String() string

type ForeignKey

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

ForeignKey struct

func NewForeignKey

func NewForeignKey(
	name string,
	dataType DataType,
) *ForeignKey

NewForeignKey fn

func (*ForeignKey) Camel

func (f *ForeignKey) Camel() string

Camel case

func (*ForeignKey) Pascal

func (f *ForeignKey) Pascal() string

Pascal case

func (*ForeignKey) Snake

func (f *ForeignKey) Snake() string

Snake case

func (*ForeignKey) Type

func (f *ForeignKey) Type() string

Type of column

type Index

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

Index data

func NewIndex

func NewIndex(
	name string,
	isUnique bool,
	isPrimary bool,
	paramPrefix string,
	columns []*IndexColumn,
) *Index

NewIndex fn

func (*Index) ColumnList

func (i *Index) ColumnList() string

ColumnList is string-friendly the list of the columns

func (*Index) Columns

func (i *Index) Columns() []*IndexColumn

Columns fn

func (*Index) Description

func (i *Index) Description() string

Description fn

func (*Index) IsPrimary

func (i *Index) IsPrimary() bool

IsPrimary fn

func (*Index) IsUnique

func (i *Index) IsUnique() bool

IsUnique fn

func (*Index) Method

func (i *Index) Method() string

Method for the index

func (*Index) Params

func (i *Index) Params() (string, error)

Params fn

func (*Index) Variables

func (i *Index) Variables() string

Variables fn

func (*Index) Where

func (i *Index) Where() string

Where fn

type IndexColumn

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

IndexColumn represents index column info.

func NewIndexColumn

func NewIndexColumn(
	name string,
	dataType DataType,
) *IndexColumn

NewIndexColumn fn

func (*IndexColumn) Camel

func (c *IndexColumn) Camel() string

Camel case

func (*IndexColumn) Name

func (c *IndexColumn) Name() string

Name of the index column

func (*IndexColumn) Pascal

func (c *IndexColumn) Pascal() string

Pascal case

func (*IndexColumn) Type

func (c *IndexColumn) Type() string

Type of the column

type Int

type Int struct{}

Int type

func (*Int) String

func (*Int) String() string

type Int64

type Int64 struct{}

Int64 type

func (*Int64) String

func (*Int64) String() string

type JSON

type JSON struct{}

JSON type

func (*JSON) String

func (*JSON) String() string

type List

type List struct{ DataType }

List type

func (*List) String

func (l *List) String() string

type Null

type Null struct{}

Null type

func (*Null) String

func (*Null) String() string

type OrderField

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

OrderField struct

func (*OrderField) Format

func (o *OrderField) Format() string

Format the order by condition

func (*OrderField) Name

func (o *OrderField) Name() string

Name fn

func (*OrderField) Pascal

func (o *OrderField) Pascal() string

Pascal case

func (*OrderField) Type

func (o *OrderField) Type() string

Type of order field

type PrimaryKey

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

PrimaryKey struct

func NewPrimaryKey

func NewPrimaryKey(
	columns []*Column,
	paramPrefix string,
) *PrimaryKey

NewPrimaryKey fn

func (*PrimaryKey) ColumnList

func (pk *PrimaryKey) ColumnList() string

ColumnList is string-friendly the list of the columns

func (*PrimaryKey) Columns

func (pk *PrimaryKey) Columns() []*Column

Columns fn

func (*PrimaryKey) Method

func (pk *PrimaryKey) Method() string

Method for the index

func (*PrimaryKey) Params

func (pk *PrimaryKey) Params() (string, error)

Params fn

func (*PrimaryKey) Variables

func (pk *PrimaryKey) Variables() string

Variables fn

func (*PrimaryKey) Where

func (pk *PrimaryKey) Where() string

Where fn

type Procedure

type Procedure struct {
	Name       string // proc name
	Params     []*ProcedureParam
	ReturnType string // return type
}

Procedure represents a stored procedure.

type ProcedureParam

type ProcedureParam struct {
	Name *string // param name
	Type *string // param type
}

ProcedureParam represents a stored procedure.

type Schema

type Schema struct {
	Provider   string
	Name       string
	Tables     []*Table
	Enums      []*Enum
	Procedures []*Procedure
}

Schema struct is a universal database structure for storing different types of database schemas

func New

func New(
	provider string,
	name string,
	tables []*Table,
	enums []*Enum,
	procedures []*Procedure,
) *Schema

New creates a new schema

type String

type String struct{}

String type

func (*String) String

func (*String) String() string

type Table

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

Table struct

func NewTable

func NewTable(
	schema string,
	name string,
	columns []*Column,
	pk *PrimaryKey,
	fks []*ForeignKey,
	idxs []*Index,
) *Table

NewTable fn

func (*Table) Camel

func (t *Table) Camel() string

Camel generates the camel case

func (*Table) Columns

func (t *Table) Columns() []*Column

Columns of the table

func (*Table) Filters

func (t *Table) Filters() (filters []*Filter)

Filters fn

func (*Table) Indexes

func (t *Table) Indexes() []*Index

Indexes of the table

func (*Table) Orders

func (t *Table) Orders() (orders []*OrderField)

Orders fn

func (*Table) Pascal

func (t *Table) Pascal() string

Pascal generates the pascal case

func (*Table) PluralCamel

func (t *Table) PluralCamel() string

PluralCamel generates the camel case

func (*Table) PrimaryKey

func (t *Table) PrimaryKey() *PrimaryKey

PrimaryKey fn

func (*Table) Returning

func (t *Table) Returning() string

Returning builds the SQL RETURNING string

func (*Table) SQLName

func (t *Table) SQLName() string

SQLName is an SQL-friendly name of the table e.g "public"."blogs"

func (*Table) Scan

func (t *Table) Scan() string

Scan builds the DB.Scan(...) params

func (*Table) Select

func (t *Table) Select() string

Select builds the SQL SELECT string

func (*Table) Short

func (t *Table) Short() string

Short generates a short variable

func (*Table) Slug

func (t *Table) Slug() string

Slug generates the slug case

func (*Table) Uniques

func (t *Table) Uniques() (uniques []*Index)

Uniques fn

Jump to

Keyboard shortcuts

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