postgres

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package postgres wraps postgres (pq) driver as an adapter for REL.

Usage:

// open postgres connection.
adapter, err := postgres.Open("postgres://postgres@localhost/rel_test?sslmode=disable")
if err != nil {
	panic(err)
}
defer adapter.Close()

// initialize REL's repo.
repo := rel.New(adapter)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter struct {
	*sql.Adapter
}

Adapter definition for postgrees database.

func Open

func Open(dsn string) (*Adapter, error)

Open postgrees connection using dsn.

func (*Adapter) Begin

func (adapter *Adapter) Begin(ctx context.Context) (rel.Adapter, error)

Begin begins a new transaction.

func (*Adapter) Insert

func (adapter *Adapter) Insert(ctx context.Context, query rel.Query, modifies map[string]rel.Modify) (interface{}, error)

Insert inserts a record to database and returns its id.

func (*Adapter) InsertAll

func (adapter *Adapter) InsertAll(ctx context.Context, query rel.Query, fields []string, bulkModifies []map[string]rel.Modify) ([]interface{}, error)

InsertAll inserts multiple records to database and returns its ids.

Jump to

Keyboard shortcuts

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