database

package
v0.0.1-alpha83 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*gorm.DB      // write pool (also used for Migrate/Seed)
	ReadDB        *gorm.DB
	Driver        string
	EncryptionKey []byte
}

DB wraps the GORM DB connection with additional context. For SQLite, separate read and write pools are used to avoid contention: the write pool has a single connection (SQLite only supports one writer), while the read pool has multiple connections for concurrent reads via WAL mode.

func New

func New(cfg *config.Config) (*DB, error)

New creates a new database connection based on configuration. For SQLite, it creates separate read and write connection pools.

func (*DB) Close

func (db *DB) Close() error

Close closes both the write and read database connections.

func (*DB) IsPostgres

func (db *DB) IsPostgres() bool

IsPostgres returns true if using PostgreSQL

func (*DB) IsSQLite

func (db *DB) IsSQLite() bool

IsSQLite returns true if using SQLite

func (*DB) Migrate

func (db *DB) Migrate() error

Migrate runs database migrations using GORM's AutoMigrate

func (*DB) Seed

func (db *DB) Seed() error

Seed creates the anonymous user and default project for no-auth mode. This is idempotent - it will not create duplicates if called multiple times.

Jump to

Keyboard shortcuts

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