sqlxtenant

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package sqlxtenant provides tenant-filtered helpers for simple sqlx-style SELECT, UPDATE, and DELETE statements.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsafeSQL = errors.New("gotenancy/sqlx: unsafe sql")
)

Functions

func ExecContext

func ExecContext(ctx context.Context, db Execer, baseSQL string, baseArgs []any, opts ...data.FilterOption) (sql.Result, error)

ExecContext runs a tenant-filtered write statement.

func GetContext

func GetContext(ctx context.Context, db Queryer, dest interface{}, baseSQL string, baseArgs []any, opts ...data.FilterOption) error

GetContext runs a tenant-filtered single-row SELECT.

func Query

func Query(ctx context.Context, baseSQL string, opts ...data.FilterOption) (string, []any, error)

Query adds the tenant filter to a base SQL statement.

func QueryWithArgs

func QueryWithArgs(ctx context.Context, baseSQL string, baseArgs []any, opts ...data.FilterOption) (string, []any, error)

QueryWithArgs adds the tenant filter to a base SQL statement and preserves existing args.

func SelectContext

func SelectContext(ctx context.Context, db Queryer, dest interface{}, baseSQL string, baseArgs []any, opts ...data.FilterOption) error

SelectContext runs a tenant-filtered SELECT.

Types

type Execer

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

Execer is implemented by *sqlx.DB and *sqlx.Tx.

type Queryer

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

Queryer is implemented by *sqlx.DB and *sqlx.Tx.

Jump to

Keyboard shortcuts

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