postgres

package
v0.0.0-...-0764311 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPGDialect

func NewPGDialect(ctx context.Context, dsn string) (dialect.Dialect, error)

NewPGDialect initializes a new PGDialect instance.

Types

type PGDialect

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

PGDialect manages a connection with PostgreSQL.

func (*PGDialect) BulkInsert

func (d *PGDialect) BulkInsert(ctx context.Context, table dialect.Table, data []map[string]interface{}) error

BulkInsert inserts multiple data a single database transaction. It disables triggers to avoid conflicts on foreign constraints.

func (*PGDialect) Close

func (d *PGDialect) Close(ctx context.Context) error

Close closes a connection.

func (*PGDialect) Columns

func (d *PGDialect) Columns(ctx context.Context, tableName string) ([]dialect.Column, error)

Columns returns sorted columns with types of a table.

func (*PGDialect) ForeignKeys

func (d *PGDialect) ForeignKeys(ctx context.Context, tableName string) (dialect.ForeignKeys, error)

ForeignKeys returns the foreign keys of a table.

func (*PGDialect) PrimaryKeyConstraint

func (d *PGDialect) PrimaryKeyConstraint(ctx context.Context, tableName string) (string, error)

PrimaryKeyConstraint returns the primary key constraint of a table.

func (*PGDialect) PrimaryKeys

func (d *PGDialect) PrimaryKeys(ctx context.Context, tableName string) ([]dialect.PrimaryKey, error)

PrimaryKeys returns primary keys of a table.

func (*PGDialect) ReferenceKeys

func (d *PGDialect) ReferenceKeys(ctx context.Context, tableName string) (dialect.ReferenceKeys, error)

ReferenceKeys returns the "Referenced by" constraints of a table.

func (*PGDialect) ResultSet

func (d *PGDialect) ResultSet(ctx context.Context, query string, args ...interface{}) ([]map[string]interface{}, error)

ResultSet executes a query and converts Rows in map[string]interface{}.

func (*PGDialect) Table

func (d *PGDialect) Table(ctx context.Context, tableName string) (dialect.Table, error)

Table returns a table with its reference keys, foreign keys, columns and primary keys.

func (*PGDialect) Tables

func (d *PGDialect) Tables(ctx context.Context) (dialect.Tables, error)

Tables returns all the tables from the database.

Jump to

Keyboard shortcuts

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