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: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址