Documentation
¶
Overview ¶
Package sqlxtenant provides tenant-filtered helpers for simple sqlx-style SELECT, UPDATE, and DELETE statements.
Index ¶
- Variables
- func ExecContext(ctx context.Context, db Execer, baseSQL string, baseArgs []any, ...) (sql.Result, error)
- func GetContext(ctx context.Context, db Queryer, dest interface{}, baseSQL string, ...) error
- func Query(ctx context.Context, baseSQL string, opts ...data.FilterOption) (string, []any, error)
- func QueryWithArgs(ctx context.Context, baseSQL string, baseArgs []any, opts ...data.FilterOption) (string, []any, error)
- func SelectContext(ctx context.Context, db Queryer, dest interface{}, baseSQL string, ...) error
- func TenantCondition(ctx context.Context, opts ...data.FilterOption) (data.Condition, error)
- type Execer
- type Queryer
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 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.
func TenantCondition ¶ added in v0.1.6
TenantCondition returns a parameterized tenant condition for explicit placement in complex SQL.
Use this helper for JOIN, GROUP BY, ORDER BY, LIMIT, or locking queries where Query cannot safely rewrite SQL. The returned condition is empty for host contexts.
Types ¶
Click to show internal directories.
Click to hide internal directories.