pg

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 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 Column

type Column struct {
	Schema     string `json:"schema,omitempty"`      // postgres type: name
	Table      string `json:"table,omitempty"`       // postgres type: name
	Name       string `json:"name,omitempty"`        // postgres type: name
	Ordinal    int16  `json:"ordinal,omitempty"`     // postgres type: int2
	Nullable   bool   `json:"nullable,omitempty"`    // postgres type: bool
	HasDefault bool   `json:"has_default,omitempty"` // postgres type: bool
	Type       string `json:"type,omitempty"`        // postgres type: name
	Comment    string `json:"comment,omitempty"`     // postgres type: text
}

Column represents a result from 'GetColumns'.

type DB

type DB interface {
	Exec(context.Context, string, ...any) (pgconn.CommandTag, error)
	Query(context.Context, string, ...any) (pgx.Rows, error)
	QueryRow(context.Context, string, ...any) pgx.Row
}

DB is the common interface for database operations.

type Enum

type Enum struct {
	ID      uint32   `json:"id,omitempty"`      // postgres type: oid
	Name    string   `json:"name,omitempty"`    // postgres type: name
	Schema  string   `json:"schema,omitempty"`  // postgres type: name
	Values  []string `json:"values,omitempty"`  // postgres type: _name
	Comment string   `json:"comment,omitempty"` // postgres type: text
}

Enum represents a result from 'GetEnums'.

type ForeignKey

type ForeignKey struct {
	ID             uint32   `json:"id,omitempty"`              // postgres type: oid
	Schema         string   `json:"schema,omitempty"`          // postgres type: name
	Name           string   `json:"name,omitempty"`            // postgres type: name
	Table          string   `json:"table,omitempty"`           // postgres type: name
	Columns        []string `json:"columns,omitempty"`         // postgres type: _name
	ForeignSchema  string   `json:"foreign_schema,omitempty"`  // postgres type: name
	ForeignTable   string   `json:"foreign_table,omitempty"`   // postgres type: name
	ForeignColumns []string `json:"foreign_columns,omitempty"` // postgres type: _name
	Comment        string   `json:"comment,omitempty"`         // postgres type: text
}

ForeignKey represents a result from 'GetForeignKeys'.

type Index

type Index struct {
	ID        uint32   `json:"id,omitempty"`         // postgres type: oid
	Schema    string   `json:"schema,omitempty"`     // postgres type: name
	Name      string   `json:"name,omitempty"`       // postgres type: name
	Table     string   `json:"table,omitempty"`      // postgres type: name
	IsUnique  bool     `json:"is_unique,omitempty"`  // postgres type: bool
	IsPrimary bool     `json:"is_primary,omitempty"` // postgres type: bool
	Columns   []string `json:"columns,omitempty"`    // postgres type: _name
	Comment   string   `json:"comment,omitempty"`    // postgres type: text
}

Index represents a result from 'GetIndexes'.

type Repo

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

func New

func New(db DB, logger zerolog.Logger) Repo

func (Repo) Get

func (r Repo) Get(ctx context.Context) (db.DB, error)

func (Repo) GetColumns

func (r Repo) GetColumns(ctx context.Context) ([]*Column, error)

GetColumns returns Column

func (Repo) GetEnums

func (r Repo) GetEnums(ctx context.Context) ([]*Enum, error)

GetEnums returns Enum

func (Repo) GetForeignKeys

func (r Repo) GetForeignKeys(ctx context.Context) ([]*ForeignKey, error)

GetForeignKeys returns ForeignKey

func (Repo) GetIndexes

func (r Repo) GetIndexes(ctx context.Context) ([]*Index, error)

GetIndexes returns Index

func (Repo) GetTables

func (r Repo) GetTables(ctx context.Context) ([]*Table, error)

GetTables returns Table

func (Repo) GetTypeNameByID

func (r Repo) GetTypeNameByID(ctx context.Context, id int64) (string, error)

type Table

type Table struct {
	ID        uint32 `json:"id,omitempty"`         // postgres type: oid
	Schema    string `json:"schema,omitempty"`     // postgres type: name
	Name      string `json:"name,omitempty"`       // postgres type: name
	Type      string `json:"type,omitempty"`       // postgres type: text
	CanUpdate bool   `json:"can_update,omitempty"` // postgres type: bool
	CanInsert bool   `json:"can_insert,omitempty"` // postgres type: bool
	CanDelete bool   `json:"can_delete,omitempty"` // postgres type: bool
	Comment   string `json:"comment,omitempty"`    // postgres type: text
}

Table represents a result from 'GetTables'.

Jump to

Keyboard shortcuts

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