easql

package module
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: MIT Imports: 5 Imported by: 0

README

easql

A sqlx + squirrel wrapper

Feature

  • Provide convenient query/exec APIs.
  • Provide same query/exec APIs to DB and Tx.

Installation

$ go get github.com/adlandh/easql

Usage

Get(interface{}, squirrel.SelectBuilder) error
Select(interface{}, squirrel.SelectBuilder) error
Insert(squirrel.InsertBuilder) (sql.Result, error)
Update(squirrel.UpdateBuilder) (sql.Result, error)
Delete(squirrel.DeleteBuilder) (sql.Result, error)
GetContext(context.Context, interface{}, squirrel.SelectBuilder) error
SelectContext(context.Context,interface{}, squirrel.SelectBuilder) error
InsertContext(context.Context,squirrel.InsertBuilder) (sql.Result, error)
UpdateContext(context.Context,squirrel.UpdateBuilder) (sql.Result, error)
DeleteContext(context.Context,squirrel.DeleteBuilder) (sql.Result, error)

Documentation

Overview

Package easql is a sqlx + squirrel wrapper

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Beginner added in v1.1.1

type Beginner interface {
	Begin() (Commiter, error)
}

type BeginnerContext added in v1.1.1

type BeginnerContext interface {
	BeginContext(context.Context) (CommiterContext, error)
}

type Commiter added in v1.1.1

type Commiter interface {
	Commit() error
	Rollback() error
	Queryer
}

type CommiterContext added in v1.1.1

type CommiterContext interface {
	Commit() error
	Rollback() error
	QueryerContext
}

type DB

type DB struct {
	Queryer
	QueryerContext
	// contains filtered or unexported fields
}

func NewDB

func NewDB(raw *sqlx.DB) *DB

func (*DB) Begin

func (db *DB) Begin() (Commiter, error)

func (*DB) BeginContext added in v1.1.0

func (db *DB) BeginContext(ctx context.Context) (CommiterContext, error)

func (*DB) Raw added in v1.1.3

func (db *DB) Raw() *sqlx.DB

type Queryer

type Queryer interface {
	Get(interface{}, squirrel.SelectBuilder) error
	Select(interface{}, squirrel.SelectBuilder) error
	Insert(squirrel.InsertBuilder) (sql.Result, error)
	Update(squirrel.UpdateBuilder) (sql.Result, error)
	Delete(squirrel.DeleteBuilder) (sql.Result, error)
}

type QueryerContext added in v1.1.0

type QueryerContext interface {
	GetContext(context.Context, interface{}, squirrel.SelectBuilder) error
	SelectContext(context.Context, interface{}, squirrel.SelectBuilder) error
	InsertContext(context.Context, squirrel.InsertBuilder) (sql.Result, error)
	UpdateContext(context.Context, squirrel.UpdateBuilder) (sql.Result, error)
	DeleteContext(context.Context, squirrel.DeleteBuilder) (sql.Result, error)
}

type RawExposer added in v1.1.3

type RawExposer interface {
	Raw() *sqlx.DB
}

type RawQueryer

type RawQueryer interface {
	Get(interface{}, string, ...interface{}) error
	Select(interface{}, string, ...interface{}) error
	Exec(string, ...interface{}) (sql.Result, error)
}

type RawQueryerContext added in v1.1.0

type RawQueryerContext interface {
	GetContext(context.Context, interface{}, string, ...interface{}) error
	SelectContext(context.Context, interface{}, string, ...interface{}) error
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
}

type Tx

type Tx struct {
	Queryer
	QueryerContext
	// contains filtered or unexported fields
}

func (*Tx) Commit

func (tx *Tx) Commit() error

func (*Tx) Rollback

func (tx *Tx) Rollback() error

Jump to

Keyboard shortcuts

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