postgres

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

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

Usage:

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

// initialize grimoire's repo.
repo := grimoire.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() (grimoire.Adapter, error)

Begin begins a new transaction.

func (*Adapter) Insert

func (adapter *Adapter) Insert(query grimoire.Query, changes map[string]interface{}, loggers ...grimoire.Logger) (interface{}, error)

Insert inserts a record to database and returns its id.

func (*Adapter) InsertAll

func (adapter *Adapter) InsertAll(query grimoire.Query, fields []string, allchanges []map[string]interface{}, loggers ...grimoire.Logger) ([]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