Categorygithub.com/klaidliadon/go-sqlhelpers
repositorypackage
0.0.0-20190208142715-babf029ae588
Repository: https://github.com/klaidliadon/go-sqlhelpers.git
Documentation: pkg.go.dev

# README

SQL Helpers

This package provides some utilities for database/sql.

JSON

The functions JSONValue and JSONScan provide helpers that store a type as JSON in a string column.

type MyType map[string]string

// Value encodes a sql value
func (m MyType) Value() (driver.Value, error) {
	return sqlhelpers.JSONValue(m)
}

// Scan decodes a sql value
func (m *MyType) Scan(value interface{}) error {
	return sqlhelpers.JSONScan(m, value)
}