database

package
v0.0.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDatabaseSession

func NewDatabaseSession(ctx context.Context, db *sqlx.DB, sessionID int64) (session.Session, error)

NewDatabaseSession creates a new session in the database using default table names. For custom table names, use NewDatabaseSessionService with option functions.

func NewDatabaseSessionService

func NewDatabaseSessionService(db *sqlx.DB, opts ...Option) (session.SessionService, error)

NewDatabaseSessionService creates a new database-backed SessionService. By default it uses the table names "sessions" and "messages". Use Option functions such as WithTablePrefix, WithSessionsTable, or WithMessagesTable to customise the table names and avoid conflicts in shared databases. Returns an error if any configured table name is not a valid SQL identifier.

Types

type Option added in v0.0.3

type Option func(*databaseSessionService)

Option is a functional option for configuring a DatabaseSessionService.

func WithMessagesTable added in v0.0.3

func WithMessagesTable(name string) Option

WithMessagesTable overrides the messages table name.

func WithSessionsTable added in v0.0.3

func WithSessionsTable(name string) Option

WithSessionsTable overrides the sessions table name.

func WithTablePrefix added in v0.0.3

func WithTablePrefix(prefix string) Option

WithTablePrefix sets a prefix for both the sessions and messages table names. For example, WithTablePrefix("myapp_") will use tables "myapp_sessions" and "myapp_messages".

Jump to

Keyboard shortcuts

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