pgadapter

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2020 License: MIT Imports: 2 Imported by: 6

README

go-pg-adapter

GoDoc Coverage Status ReportCard License

Simple adapter interface and implementations for different PostgreSQL drivers for Go.

package pgadapter

import (
	"context"
	"errors"
)

var (
	// ErrNoRows is the driver-agnostic error returned when no record is found
	ErrNoRows = errors.New("sql: no rows in result set")
	// ErrManyRows is the driver-agnostic error returned when more than one record is found
	// while only one was expected
	ErrManyRows = errors.New("sql: more than one row in result set")
)

// Adapter represents DB access layer interface for different PostgreSQL drivers
type Adapter interface {
	Exec(ctx context.Context, query string, args ...interface{}) error
	SelectOne(ctx context.Context, dst interface{}, query string, args ...interface{}) error
}

Install

$ go get -u -v github.com/vgarvardt/go-pg-adapter

PostgreSQL drivers

The package bundles the following adapter implementations:

Testing

Linter and tests are running for every Pul Request, but it is possible to run linter and tests locally using docker and make.

Run linter: make link. This command runs liner in docker container with the project source code mounted.

Run tests: make test. This command runs project dependencies in docker containers if they are not started yet and runs go tests with coverage.

MIT License

Copyright (c) 2020 Vladimir Garvardt

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoRows is the driver-agnostic error returned when no record is found
	ErrNoRows = errors.New("sql: no rows in result set")
	// ErrManyRows is the driver-agnostic error returned when more than one record is found
	// while only one was expected
	ErrManyRows = errors.New("sql: more than one row in result set")
)

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Exec(ctx context.Context, query string, args ...interface{}) error
	SelectOne(ctx context.Context, dst interface{}, query string, args ...interface{}) error
}

Adapter represents DB access layer interface for different PostgreSQL drivers

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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