sqlhelpers

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

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

Go to latest
Published: Feb 8, 2019 License: MIT Imports: 4 Imported by: 0

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)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONScan

func JSONScan(i, value interface{}) error

JSONScan decodes a JSON as an SQL value

func JSONValue

func JSONValue(i interface{}) (driver.Value, error)

JSONValue encodes a SQL value as JSON

Types

This section is empty.

Jump to

Keyboard shortcuts

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