seacle

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 12 Imported by: 6

README

seacle

database/sql object mapping helper

License

The MIT License (MIT)

(c) 2020 acidlemon.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

func Delete(ctx Context, e Executable, in Modifiable) error

func Insert

func Insert(ctx Context, e Executable, in Modifiable) (int64, error)

func QueryContext added in v0.2.2

func QueryContext(ctx Context, s Selectable, query string, args ...interface{}) (*sql.Rows, error)

func QueryRowContext added in v0.2.2

func QueryRowContext(ctx Context, s Selectable, query string, args ...interface{}) *sql.Row

func Select

func Select(ctx Context, s Selectable, out interface{}, fragment string, args ...interface{}) error

func SelectRow

func SelectRow(ctx Context, s Selectable, out interface{}, fragment string, args ...interface{}) error

func Update

func Update(ctx Context, e Executable, in Modifiable) error

Types

type Context

type Context = context.Context

type Executable

type Executable interface {
	Selectable
	ExecContext(ctx Context, query string, args ...interface{}) (sql.Result, error)
}

type Generator

type Generator struct {
	Tag string
}

func (Generator) Generate

func (g Generator) Generate(tp reflect.Type, pkg, table, destfile string) error

type Mappable

type Mappable interface {
	Table() string
	Columns() []string
	Scan(r RowScanner) error
}

type Modifiable

type Modifiable interface {
	Table() string
	PrimaryKeys() []string
	PrimaryValues() []interface{}
	ValueColumns() []string
	Values() []interface{}
	AutoIncrementColumn() string
}

type RowScanner

type RowScanner interface {
	Scan(dest ...interface{}) error
}

type Selectable

type Selectable interface {
	QueryContext(ctx Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx Context, query string, args ...interface{}) *sql.Row
}

Jump to

Keyboard shortcuts

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