dotsqlx

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: GPL-2.0 Imports: 4 Imported by: 2

README

dotsqlx

GoDoc Build status Go Report Card

Dotsql wrapper allowing seemless work with jmoiron/sqlx

Installation

go get github.com/swithek/dotsqlx

Usage

// connect to db and obtain a new sqlx db instance.
dbx, err := sqlx.Connect("postgres", "user=foo dbname=bar sslmode=disable")
if err != nil {
    // handle error
}

// load your queries and obtain a new dotsql instance.
dot, err := dotsql.LoadFromFile("./queries.sql")
if err != nil {
    // handle error
}

// wrap dotsql's instance, extend its logic and allow sqlx support.
dotx := dotsqlx.Wrap(dot)

// execute named dotsql queries in sqlx methods.
var users []Users
if err = dotx.Select(dbx, &users, "select_users"); err != nil {
    // handle error
}

// you can use dotsql's methods as well.
res, err := dotx.Exec(dbx, "insert_user")
if err != nil {
    // handle error
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DotSqlx

type DotSqlx struct {
	*dotsql.DotSql
}

DotSqlx wraps dotsql.DotSql instance and allows seamless work with jmoiron/sqlx.

func Wrap

func Wrap(d *dotsql.DotSql) *DotSqlx

Wrap creates a new DotSqlx instance and embeds provided dotsql.DotSql instance into it.

func (DotSqlx) BindNamed

func (d DotSqlx) BindNamed(dbx NamedBinder, name string, arg interface{}) (string, []interface{}, error)

BindNamed is a wrapper for jmoiron/sqlx's BindNamed(), using dotsql named query.

func (DotSqlx) Get

func (d DotSqlx) Get(dbx Getter, dest interface{}, name string, args ...interface{}) error

Get is a wrapper for jmoiron/sqlx's Get(), using dotsql named query.

func (DotSqlx) GetContext

func (d DotSqlx) GetContext(ctx context.Context, dbx GetterContext, dest interface{}, name string, args ...interface{}) error

GetContext is a wrapper for jmoiron/sqlx's GetContext(), using dotsql named query.

func (DotSqlx) In

func (d DotSqlx) In(name string, args ...interface{}) (string, []interface{}, error)

In is a wrapper for jmoiron/sqlx's In(), using dotsql named query.

func (DotSqlx) MustExec

func (d DotSqlx) MustExec(dbx MustExecer, name string, args ...interface{}) sql.Result

MustExec is a wrapper for jmoiron/sqlx's MustExec(), using dotsql named query.

func (DotSqlx) MustExecContext

func (d DotSqlx) MustExecContext(ctx context.Context, dbx MustExecerContext, name string, args ...interface{}) sql.Result

MustExecContext is a wrapper for jmoiron/sqlx's MustExecContext(), using dotsql named query.

func (DotSqlx) NamedExec

func (d DotSqlx) NamedExec(dbx NamedExecer, name string, arg interface{}) (sql.Result, error)

NamedExec is a wrapper for jmoiron/sqlx's NamedExec(), using dotsql named query.

func (DotSqlx) NamedExecContext

func (d DotSqlx) NamedExecContext(ctx context.Context, dbx NamedExecerContext, name string, arg interface{}) (sql.Result, error)

NamedExecContext is a wrapper for jmoiron/sqlx's NamedExecContext(), using dotsql named query.

func (DotSqlx) NamedQuery

func (d DotSqlx) NamedQuery(dbx NamedQueryer, name string, arg interface{}) (*sqlx.Rows, error)

NamedQuery is a wrapper for jmoiron/sqlx's NamedQuery(), using dotsql named query.

func (DotSqlx) NamedQueryContext

func (d DotSqlx) NamedQueryContext(ctx context.Context, dbx NamedQueryerContext, name string, arg interface{}) (*sqlx.Rows, error)

NamedQueryContext is a wrapper for jmoiron/sqlx's NamedQueryContext(), using dotsql named query.

func (DotSqlx) PrepareNamed

func (d DotSqlx) PrepareNamed(dbx NamedPreparer, name string) (*sqlx.NamedStmt, error)

PrepareNamed is a wrapper for jmoiron/sqlx's PrepareNamed(), using dotsql named query.

func (DotSqlx) PrepareNamedContext

func (d DotSqlx) PrepareNamedContext(ctx context.Context, dbx NamedPreparerContext, name string) (*sqlx.NamedStmt, error)

PrepareNamedContext is a wrapper for jmoiron/sqlx's PrepareNamedContext(), using dotsql named query.

func (DotSqlx) Preparex

func (d DotSqlx) Preparex(dbx Preparerx, name string) (*sqlx.Stmt, error)

Preparex is a wrapper for jmoiron/sqlx's Preparex(), using dotsql named query.

func (DotSqlx) PreparexContext

func (d DotSqlx) PreparexContext(ctx context.Context, dbx PreparerxContext, name string) (*sqlx.Stmt, error)

PreparexContext is a wrapper for jmoiron/sqlx's PreparexContext(), using dotsql named query.

func (DotSqlx) QueryRowx

func (d DotSqlx) QueryRowx(dbx QueryRowerx, name string, args ...interface{}) (*sqlx.Row, error)

QueryRowx is a wrapper for jmoiron/sqlx's QueryRowx(), using dotsql named query.

func (DotSqlx) QueryRowxContext

func (d DotSqlx) QueryRowxContext(ctx context.Context, dbx QueryRowerxContext, name string, args ...interface{}) (*sqlx.Row, error)

QueryRowxContext is a wrapper for jmoiron/sqlx's QueryRowxContext(), using dotsql named query.

func (DotSqlx) Queryx

func (d DotSqlx) Queryx(dbx Queryerx, name string, args ...interface{}) (*sqlx.Rows, error)

Queryx is a wrapper for jmoiron/sqlx's Queryx(), using dotsql named query.

func (DotSqlx) QueryxContext

func (d DotSqlx) QueryxContext(ctx context.Context, dbx QueryerxContext, name string, args ...interface{}) (*sqlx.Rows, error)

QueryxContext is a wrapper for jmoiron/sqlx's QueryxContext(), using dotsql named query.

func (DotSqlx) Rebind

func (d DotSqlx) Rebind(dbx Rebinder, name string) (string, error)

Rebind is a wrapper for jmoiron/sqlx's Rebind(), using dotsql named query.

func (DotSqlx) Select

func (d DotSqlx) Select(dbx Selecter, dest interface{}, name string, args ...interface{}) error

Select is a wrapper for jmoiron/sqlx's Select(), using dotsql named query.

func (DotSqlx) SelectContext

func (d DotSqlx) SelectContext(ctx context.Context, dbx SelecterContext, dest interface{}, name string, args ...interface{}) error

SelectContext is a wrapper for jmoiron/sqlx's SelectContext(), using dotsql named query.

type Getter

type Getter interface {
	Get(dest interface{}, query string, args ...interface{}) error
}

Getter is an interface used by Get.

type GetterContext

type GetterContext interface {
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}

GetterContext is an interface used by GetContext.

type MustExecer

type MustExecer interface {
	MustExec(query string, args ...interface{}) sql.Result
}

MustExecer is an interface used by MustExec.

type MustExecerContext

type MustExecerContext interface {
	MustExecContext(ctx context.Context, query string, args ...interface{}) sql.Result
}

MustExecerContext is an interface used by MustExecContext.

type NamedBinder

type NamedBinder interface {
	BindNamed(query string, arg interface{}) (string, []interface{}, error)
}

NamedBinder is an interface used by BindNamed.

type NamedExecer

type NamedExecer interface {
	NamedExec(query string, arg interface{}) (sql.Result, error)
}

NamedExecer is an interface used by NamedExec.

type NamedExecerContext

type NamedExecerContext interface {
	NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
}

NamedExecerContext is an interface used by NamedExecContext.

type NamedPreparer

type NamedPreparer interface {
	PrepareNamed(query string) (*sqlx.NamedStmt, error)
}

NamedPreparer is an interface used by PrepareNamed.

type NamedPreparerContext

type NamedPreparerContext interface {
	PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)
}

NamedPreparerContext is an interface used by PrepareNamedContext.

type NamedQueryer

type NamedQueryer interface {
	NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
}

NamedQueryer is an interface used by NamedQuery.

type NamedQueryerContext

type NamedQueryerContext interface {
	NamedQueryContext(ctx context.Context, query string, arg interface{}) (*sqlx.Rows, error)
}

NamedQueryerContext is an interface used by NamedQueryContext.

type Preparerx

type Preparerx interface {
	Preparex(query string) (*sqlx.Stmt, error)
}

Preparerx is an interface used by Preparex.

type PreparerxContext

type PreparerxContext interface {
	PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
}

PreparerxContext is an interface used by PreparexContext.

type QueryRowerx

type QueryRowerx interface {
	QueryRowx(query string, args ...interface{}) *sqlx.Row
}

QueryRowerx is an interface used by QueryRowx.

type QueryRowerxContext

type QueryRowerxContext interface {
	QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
}

QueryRowerxContext is an interface used by QueryRowxContext.

type Queryerx

type Queryerx interface {
	Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
}

Queryerx is an interface used by Queryx.

type QueryerxContext

type QueryerxContext interface {
	QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
}

QueryerxContext is an interface used by QueryxContext.

type Rebinder

type Rebinder interface {
	Rebind(query string) string
}

Rebinder is an interface used by Rebind.

type Selecter

type Selecter interface {
	Select(dest interface{}, query string, args ...interface{}) error
}

Selecter is an interface used by Select.

type SelecterContext

type SelecterContext interface {
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}

SelecterContext is an interface used by SelectContext.

Jump to

Keyboard shortcuts

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