session

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotInTransaction is returned when attempting transaction operations outside a transaction
	ErrNotInTransaction = errors.New("session is not in a transaction")

	// ErrAlreadyInTransaction is returned when attempting to start a transaction while already in one
	ErrAlreadyInTransaction = errors.New("session is already in a transaction")
)

Functions

This section is empty.

Types

type Session

type Session struct {
	// contains filtered or unexported fields
}

Session represents a database session for executing queries

func NewSession added in v2.0.1

func NewSession(ctx context.Context, eng *engine.Engine) *Session

NewSession creates a new session bound to the engine

func (*Session) Begin added in v2.0.1

func (s *Session) Begin() error

Begin starts a transaction on the session

func (*Session) Close

func (s *Session) Close() error

Close closes the session (rolls back transaction if active)

func (*Session) Commit

func (s *Session) Commit() error

Commit commits the transaction (only valid if session is in a transaction)

func (*Session) Context

func (s *Session) Context() context.Context

Context returns the session context

func (*Session) Delete

func (s *Session) Delete(tbl interface{}) *query.DeleteBuilder

Delete creates a new DELETE query builder

func (*Session) Engine

func (s *Session) Engine() *engine.Engine

Engine returns the underlying engine

func (*Session) Exec

func (s *Session) Exec(query string, args ...interface{}) (sql.Result, error)

Exec executes a raw SQL statement

func (*Session) GetTableColumns

func (s *Session) GetTableColumns(tbl interface{}) []*table.ColumnRef

GetTableColumns extracts column references from a Table[T] object

func (*Session) GetTableName

func (s *Session) GetTableName(tbl interface{}) string

GetTableName extracts the table name from a Table[T] object

func (*Session) InTransaction

func (s *Session) InTransaction() bool

InTransaction returns true if the session is in a transaction

func (*Session) Insert

func (s *Session) Insert(tbl interface{}) *query.InsertBuilder

Insert creates a new INSERT query builder

func (*Session) Query

func (s *Session) Query(tbl interface{}) *query.SelectBuilder

Query creates a new SELECT query builder

func (*Session) QueryRow

func (s *Session) QueryRow(query string, args ...interface{}) *sql.Row

QueryRow executes a query that returns a single row

func (*Session) QueryRows

func (s *Session) QueryRows(query string, args ...interface{}) (*sql.Rows, error)

QueryRows executes a query that returns multiple rows

func (*Session) Rollback

func (s *Session) Rollback() error

Rollback rolls back the transaction (only valid if session is in a transaction)

func (*Session) Update

func (s *Session) Update(tbl interface{}) *query.UpdateBuilder

Update creates a new UPDATE query builder

Jump to

Keyboard shortcuts

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