models

package
v2.0.2-0...-debcd52 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package models contains generated code for schema 'public'.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(s string, v ...interface{})

Errorf logs an error message using the package error logger.

func Logf

func Logf(s string, v ...interface{})

Logf logs a message using the package logger.

func PostgresSchema

func PostgresSchema(ctx context.Context, db DB) (string, error)

PostgresSchema retrieves the schema.

func PostgresViewCreate

func PostgresViewCreate(ctx context.Context, db DB, schema, id string, query []string) (sql.Result, error)

PostgresViewCreate creates a view for introspection.

func PostgresViewDrop

func PostgresViewDrop(ctx context.Context, db DB, schema, id string) (sql.Result, error)

PostgresViewDrop drops a view created for introspection.

func PostgresViewSchema

func PostgresViewSchema(ctx context.Context, db DB, id string) (string, error)

PostgresViewSchema retrieves the schema for a view created for introspection.

func SetErrorLogger

func SetErrorLogger(logger interface{})

SetErrorLogger sets the package error logger. Valid logger types:

io.Writer
func(string, ...interface{}) (int, error) // fmt.Printf
func(string, ...interface{}) // log.Printf

func SetLogger

func SetLogger(logger interface{})

SetLogger sets the package logger. Valid logger types:

io.Writer
func(string, ...interface{}) (int, error) // fmt.Printf
func(string, ...interface{}) // log.Printf

Types

type Column

type Column struct {
	FieldOrdinal  int            `json:"field_ordinal"`  // field_ordinal
	ColumnName    string         `json:"column_name"`    // column_name
	DataType      string         `json:"data_type"`      // data_type
	NotNull       bool           `json:"not_null"`       // not_null
	DefaultValue  sql.NullString `json:"default_value"`  // default_value
	IsPrimaryKey  bool           `json:"is_primary_key"` // is_primary_key
	ColumnComment string         `json:"column_comment"` // column_comment
}

Column is a column.

func PostgresTableColumns

func PostgresTableColumns(ctx context.Context, db DB, schema, table string, sys bool) ([]*Column, error)

PostgresTableColumns runs a custom query, returning results as Column.

type Constraint

type Constraint struct {
	KeyType       string `json:"key_type"`        // key_type
	UniqueKeyName string `json:"unique_key_name"` // unique_key_name
	TableName     string `json:"table_name"`      // table_name
	ColumnName    string `json:"column_name"`     // column_name
	TableComment  string `json:"table_comment"`   // table_comment
	ColumnComment string `json:"column_comment"`  // column_comment
	RefTableName  string `json:"ref_table_name"`  // ref_table_name
	RefColumnName string `json:"ref_column_name"` // ref_column_name
}

Constraint represents all constraints in a schema.

func PostgresConstraints

func PostgresConstraints(ctx context.Context, db DB, schema string) ([]*Constraint, error)

PostgresConstraints runs a custom query, returning results as Constraint.

type DB

type DB interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

DB is the common interface for database operations that can be used with types from schema 'public'.

This works with both database/sql.DB and database/sql.Tx.

type Enum

type Enum struct {
	EnumName string `json:"enum_name"` // enum_name
	Schema   string `json:"schema"`    // schema
}

Enum is a enum.

func PostgresEnums

func PostgresEnums(ctx context.Context, db DB, schema string) ([]*Enum, error)

PostgresEnums runs a custom query, returning results as Enum.

type EnumValue

type EnumValue struct {
	EnumValue  string `json:"enum_value"`  // enum_value
	ConstValue int    `json:"const_value"` // const_value
}

EnumValue is a enum value.

func PostgresEnumValues

func PostgresEnumValues(ctx context.Context, db DB, schema, enum string) ([]*EnumValue, error)

PostgresEnumValues runs a custom query, returning results as EnumValue.

type ErrInsertFailed

type ErrInsertFailed struct {
	Err error
}

ErrInsertFailed is the insert failed error.

func (*ErrInsertFailed) Error

func (err *ErrInsertFailed) Error() string

Error satisfies the error interface.

func (*ErrInsertFailed) Unwrap

func (err *ErrInsertFailed) Unwrap() error

Unwrap satisfies the unwrap interface.

type ErrUpdateFailed

type ErrUpdateFailed struct {
	Err error
}

ErrUpdateFailed is the update failed error.

func (*ErrUpdateFailed) Error

func (err *ErrUpdateFailed) Error() string

Error satisfies the error interface.

func (*ErrUpdateFailed) Unwrap

func (err *ErrUpdateFailed) Unwrap() error

Unwrap satisfies the unwrap interface.

type ErrUpsertFailed

type ErrUpsertFailed struct {
	Err error
}

ErrUpsertFailed is the upsert failed error.

func (*ErrUpsertFailed) Error

func (err *ErrUpsertFailed) Error() string

Error satisfies the error interface.

func (*ErrUpsertFailed) Unwrap

func (err *ErrUpsertFailed) Unwrap() error

Unwrap satisfies the unwrap interface.

type Error

type Error string

Error is an error.

const (
	// ErrAlreadyExists is the already exists error.
	ErrAlreadyExists Error = "already exists"
	// ErrDoesNotExist is the does not exist error.
	ErrDoesNotExist Error = "does not exist"
	// ErrMarkedForDeletion is the marked for deletion error.
	ErrMarkedForDeletion Error = "marked for deletion"
)

Error values.

func (Error) Error

func (err Error) Error() string

Error satisfies the error interface.

type ForeignKey

type ForeignKey struct {
	ForeignKeyName string `json:"foreign_key_name"` // foreign_key_name
	TableName      string `json:"table_name"`       // table_name
	ColumnName     string `json:"column_name"`      // column_name
	RefTableName   string `json:"ref_table_name"`   // ref_table_name
	RefColumnName  string `json:"ref_column_name"`  // ref_column_name
	KeyID          int    `json:"key_id"`           // key_id
}

ForeignKey is a foreign key.

func PostgresTableForeignKeys

func PostgresTableForeignKeys(ctx context.Context, db DB, schema, table string) ([]*ForeignKey, error)

PostgresTableForeignKeys runs a custom query, returning results as ForeignKey.

type Generated

type Generated struct {
	ColumnName string `json:"column_name"` // column_name
}

Generated represents generated columns.

func PostgresTableGenerations

func PostgresTableGenerations(ctx context.Context, db DB, schema, table string) ([]*Generated, error)

PostgresTableGenerations runs a custom query, returning results as Generated.

type Index

type Index struct {
	IndexDefinition string `json:"index_definition"` // index_definition
	IndexName       string `json:"index_name"`       // index_name
	IsUnique        bool   `json:"is_unique"`        // is_unique
	IsPrimary       bool   `json:"is_primary"`       // is_primary
}

Index is a index.

func PostgresTableIndexes

func PostgresTableIndexes(ctx context.Context, db DB, schema, table string) ([]*Index, error)

PostgresTableIndexes runs a custom query, returning results as Index.

type IndexColumn

type IndexColumn struct {
	SeqNo      int    `json:"seq_no"`      // seq_no
	Cid        int    `json:"cid"`         // cid
	ColumnName string `json:"column_name"` // column_name
}

IndexColumn is a index column.

func PostgresIndexColumns

func PostgresIndexColumns(ctx context.Context, db DB, schema, index string) ([]*IndexColumn, error)

PostgresIndexColumns runs a custom query, returning results as IndexColumn.

type PostgresColOrder

type PostgresColOrder struct {
	Ord string `json:"ord"` // ord
}

PostgresColOrder is a index column order.

func PostgresGetColOrder

func PostgresGetColOrder(ctx context.Context, db DB, schema, index string) (*PostgresColOrder, error)

PostgresGetColOrder runs a custom query, returning results as PostgresColOrder.

type Proc

type Proc struct {
	ProcID     string `json:"proc_id"`     // proc_id
	ProcName   string `json:"proc_name"`   // proc_name
	ProcType   string `json:"proc_type"`   // proc_type
	ReturnType string `json:"return_type"` // return_type
	ReturnName string `json:"return_name"` // return_name
	ProcDef    string `json:"proc_def"`    // proc_def
}

Proc is a stored procedure.

func PostgresProcs

func PostgresProcs(ctx context.Context, db DB, schema string) ([]*Proc, error)

PostgresProcs runs a custom query, returning results as Proc.

type ProcParam

type ProcParam struct {
	ParamName string `json:"param_name"` // param_name
	ParamType string `json:"param_type"` // param_type
}

ProcParam is a stored procedure param.

func PostgresProcParams

func PostgresProcParams(ctx context.Context, db DB, schema, id string) ([]*ProcParam, error)

PostgresProcParams runs a custom query, returning results as ProcParam.

type Sequence

type Sequence struct {
	ColumnName string `json:"column_name"` // column_name
}

Sequence is a sequence.

func PostgresTableSequences

func PostgresTableSequences(ctx context.Context, db DB, schema, table string) ([]*Sequence, error)

PostgresTableSequences runs a custom query, returning results as Sequence.

type Table

type Table struct {
	Type       string `json:"type"`        // type
	TableName  string `json:"table_name"`  // table_name
	ManualPk   bool   `json:"manual_pk"`   // manual_pk
	ViewDef    string `json:"view_def"`    // view_def
	MatviewDef string `json:"matview_def"` // matview_def
}

Table is a table.

func PostgresTables

func PostgresTables(ctx context.Context, db DB, schema, typ string) ([]*Table, error)

PostgresTables runs a custom query, returning results as Table.

Jump to

Keyboard shortcuts

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