jssql

package
v0.40.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const DefaultMaxRows = 1000

DefaultMaxRows caps query results unless overridden by WithMaxRows.

View Source
const Name = "sql"

Name is the library identifier and the global binding installed into the runtime.

Variables

View Source
var (
	// ErrExecuteDisabled is thrown into the script when sql.execute is called on a
	// library built without WithExecute.
	ErrExecuteDisabled = errors.New("jssql: execute disabled")
	// ErrQueryNotReadOnly is thrown into the script when sql.queryList receives a
	// statement the read-only guard rejects: a non-read statement, a
	// data-modifying CTE, a dialect-specific side-effecting function, or SQL
	// the parser cannot understand (the guard fails closed).
	ErrQueryNotReadOnly = errors.New("jssql: statement is not read-only")
	// ErrTooManyRows is thrown into the script when a query yields more rows
	// than the configured limit.
	ErrTooManyRows = errors.New("jssql: result exceeds row limit")
)

Functions

func New

func New(db orm.DB, kind config.DBKind, opts ...Option) js.Lib

New builds the sql library over db. The caller picks the data source — typically the primary orm.DB, or a specific one taken from datasource.Registry — and thereby decides what the scripts can reach. kind is the dialect of db, used by the read-only guard to select the dialect's side-effecting-function denylist.

Types

type Option

type Option func(*libConfig)

Option customizes the sql library.

func WithExecute

func WithExecute() Option

WithExecute enables sql.execute for mutating statements. Without it the library is read-only and execute throws ErrExecuteDisabled.

func WithMaxRows

func WithMaxRows(n int) Option

WithMaxRows caps the number of rows a query may return; exceeding the cap fails the query instead of silently truncating the result.

Jump to

Keyboard shortcuts

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