Documentation
¶
Overview ¶
Package postgres provides the PostgreSQL database driver implementation.
Index ¶
- func NewPostgreSQLDriver() database.DatabaseDriver
- type PostgreSQLDriver
- func (d *PostgreSQLDriver) BeginTx(ctx context.Context) (database.Transaction, error)
- func (d *PostgreSQLDriver) Close() error
- func (d *PostgreSQLDriver) Connect(ctx context.Context, dsn string) error
- func (d *PostgreSQLDriver) CreateTable(schema database.TableSchema) (database.Query, error)
- func (d *PostgreSQLDriver) Delete(table string, where string, whereArgs ...interface{}) (database.Query, error)
- func (d *PostgreSQLDriver) DropTable(tableName string) (database.Query, error)
- func (d *PostgreSQLDriver) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (d *PostgreSQLDriver) Insert(table string, data map[string]interface{}) (database.Query, error)
- func (d *PostgreSQLDriver) MapType(schemaType string) string
- func (d *PostgreSQLDriver) Ping(ctx context.Context) error
- func (d *PostgreSQLDriver) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (d *PostgreSQLDriver) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (d *PostgreSQLDriver) Select(table string, columns []string, where string, whereArgs ...interface{}) (database.Query, error)
- func (d *PostgreSQLDriver) SupportsArrays() bool
- func (d *PostgreSQLDriver) SupportsLastInsertId() bool
- func (d *PostgreSQLDriver) SupportsReturning() bool
- func (d *PostgreSQLDriver) TableExists(tableName string) (bool, error)
- func (d *PostgreSQLDriver) Update(table string, data map[string]interface{}, where string, ...) (database.Query, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPostgreSQLDriver ¶
func NewPostgreSQLDriver() database.DatabaseDriver
NewPostgreSQLDriver creates a new PostgreSQL driver.
Types ¶
type PostgreSQLDriver ¶
type PostgreSQLDriver struct {
// contains filtered or unexported fields
}
PostgreSQLDriver implements the DatabaseDriver interface for PostgreSQL.
func (*PostgreSQLDriver) BeginTx ¶
func (d *PostgreSQLDriver) BeginTx(ctx context.Context) (database.Transaction, error)
BeginTx starts a new transaction.
func (*PostgreSQLDriver) Close ¶
func (d *PostgreSQLDriver) Close() error
Close closes the database connection.
func (*PostgreSQLDriver) Connect ¶
func (d *PostgreSQLDriver) Connect(ctx context.Context, dsn string) error
Connect establishes a connection to PostgreSQL.
func (*PostgreSQLDriver) CreateTable ¶
func (d *PostgreSQLDriver) CreateTable(schema database.TableSchema) (database.Query, error)
CreateTable generates and returns a CREATE TABLE query for PostgreSQL.
func (*PostgreSQLDriver) Delete ¶
func (d *PostgreSQLDriver) Delete(table string, where string, whereArgs ...interface{}) (database.Query, error)
Delete generates a DELETE query.
func (*PostgreSQLDriver) DropTable ¶
func (d *PostgreSQLDriver) DropTable(tableName string) (database.Query, error)
DropTable generates a DROP TABLE query.
func (*PostgreSQLDriver) Exec ¶
func (d *PostgreSQLDriver) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
Exec executes a query without returning rows.
func (*PostgreSQLDriver) Insert ¶
func (d *PostgreSQLDriver) Insert(table string, data map[string]interface{}) (database.Query, error)
Insert generates an INSERT query with RETURNING support.
func (*PostgreSQLDriver) MapType ¶
func (d *PostgreSQLDriver) MapType(schemaType string) string
MapType maps schema types to PostgreSQL types.
func (*PostgreSQLDriver) Ping ¶
func (d *PostgreSQLDriver) Ping(ctx context.Context) error
Ping checks if the connection is alive.
func (*PostgreSQLDriver) Query ¶
func (d *PostgreSQLDriver) Query(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
Query executes a query that returns rows.
func (*PostgreSQLDriver) QueryRow ¶
func (d *PostgreSQLDriver) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
QueryRow executes a query that returns at most one row.
func (*PostgreSQLDriver) Select ¶
func (d *PostgreSQLDriver) Select(table string, columns []string, where string, whereArgs ...interface{}) (database.Query, error)
Select generates a SELECT query.
func (*PostgreSQLDriver) SupportsArrays ¶
func (d *PostgreSQLDriver) SupportsArrays() bool
SupportsArrays returns true for PostgreSQL.
func (*PostgreSQLDriver) SupportsLastInsertId ¶
func (d *PostgreSQLDriver) SupportsLastInsertId() bool
SupportsLastInsertId returns false for PostgreSQL.
func (*PostgreSQLDriver) SupportsReturning ¶
func (d *PostgreSQLDriver) SupportsReturning() bool
SupportsReturning returns true for PostgreSQL.
func (*PostgreSQLDriver) TableExists ¶
func (d *PostgreSQLDriver) TableExists(tableName string) (bool, error)
TableExists checks if a table exists.