typed

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: MIT Imports: 3 Imported by: 0

README

go-typed-sql

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create[T DatabaseSerializable[T]](db *DB, obj T) error

func Delete

func Delete[T DatabaseSerializable[T]](db *DB, obj T) error

func NewTable

func NewTable[T DatabaseSerializable[T]](db *DB, obj T) error

func Read

func Read[T DatabaseSerializable[T]](db *DB, obj T) ([]T, error)

func Update

func Update[T DatabaseSerializable[T]](db *DB, obj T) error

Types

type DB

type DB struct {
	*sql.DB
}

func NewDB

func NewDB(dataSourceName string) (*DB, error)

type DatabaseSerializable

type DatabaseSerializable[T any] interface {
	TableName() string
	Columns() []Pair[string, interface{}]
	PrimaryKeyColumn() string
	PrimaryKeyValue() interface{}
	ScanRow(*sql.Rows) error
	New() T
}

type Pair

type Pair[A any, B any] struct {
	First  A
	Second B
}

Jump to

Keyboard shortcuts

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