Documentation
¶
Overview ¶
Package db owns database setup, dialect adaptation, and schema migrations.
Index ¶
- func ParseBool(value any) (bool, error)
- func ParseDate(value any) (time.Time, error)
- func ParseTime(value any) (time.Time, error)
- func ParseUUID(value any) (uuid.UUID, error)
- type DB
- func (d *DB) BoolArg(value bool) any
- func (d *DB) DateArg(value time.Time) any
- func (d *DB) Dialect() Dialect
- func (d *DB) Initialized(ctx context.Context) (bool, error)
- func (d *DB) SQL(query string) string
- func (d *DB) TimeArg(value time.Time) any
- func (d *DB) UUIDArg(value uuid.UUID) any
- func (d *DB) WasNew() bool
- func (d *DB) WithTx(ctx context.Context, fn func(*sql.Tx) error) error
- type Dialect
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DB ¶
DB embeds database/sql and carries the type conversion rules for one dialect.
func Open ¶
Open connects to the database, verifies the migration history and applies the pending migrations. Before changing a database that already holds tables it writes a private backup into backupDir; if that is impossible it fails without touching the database.
func (*DB) SQL ¶
SQL rewrites positional ? placeholders to PostgreSQL's $n syntax. SQL used by this project keeps placeholders out of quoted strings and comments.