database

package
v0.0.1-test9 Latest Latest
Warning

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

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

Documentation

Overview

Package database initializes Meta's GORM database connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*gorm.DB
	ReadDB *gorm.DB
	Driver string
}

DB wraps the Meta service database connections.

SQLite uses separate write and read pools: the write pool is limited to one connection for SQLite's single-writer model, while the read pool allows concurrent read queries through WAL mode. Postgres uses the same GORM handle for reads and writes.

func New

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

New creates the configured database connection.

func (*DB) Close

func (db *DB) Close() error

Close closes the write and read database connections.

func (*DB) IsPostgres

func (db *DB) IsPostgres() bool

IsPostgres returns true when the database uses Postgres.

func (*DB) IsSQLite

func (db *DB) IsSQLite() bool

IsSQLite returns true when the database uses SQLite.

func (*DB) Migrate

func (db *DB) Migrate() error

Migrate runs Meta's GORM migrations.

Jump to

Keyboard shortcuts

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