pgorp

package module
v0.0.0-...-a579bcd Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2013 License: MIT Imports: 6 Imported by: 0

README

Provides conversion of Postgres types for gorp.

Currently only implements []int64 as ArrayInt64. Patches welcome.

Usage

During gorp initialization, set the instance TypeConverter to pgorp's TypeConverter:

orm = new(gorp.DbMap)
...
orm.TypeConverter = pgorp.TypeConverter{}

Later on, use the pgorp.ArrayInt64 type for integer array column definitions:

type SchoolDistrict {
  Name string
  SchoolIds pgorp.ArrayInt64 `db:"school_ids"`
}

Credits

Based largely on work done by Andrew Harris in this gist, referenced in gorp issue #5.

License

MIT License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayInt64

type ArrayInt64 []int64

Database type for struct definitions

type TypeConverter

type TypeConverter struct{}

Converter type to assign to gorp

func (TypeConverter) FromDb

func (c TypeConverter) FromDb(target interface{}) (gorp.CustomScanner, bool)

Called by gorp to deserialize database values to custom types

func (TypeConverter) ToDb

func (c TypeConverter) ToDb(val interface{}) (interface{}, error)

Called by gorp to serialize custom types to database values

Jump to

Keyboard shortcuts

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