client

package
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaskDSN

func MaskDSN(raw string) string

MaskDSN masks sensitive information in a PostgreSQL Data Source Name (DSN) or connection string.

The function handles two formats: 1. Standard URL format: "postgres://user:password@host:port/dbname?param=value" 2. PostgreSQL-style key-value connection string: "host=localhost port=5432 user=postgres password=secret"

It ensures that sensitive fields such as passwords, keys, and client secrets are replaced with asterisks before being logged or displayed.

func New

func New(opts ...Option) (*gorm.DB, error)

Types

type Option

type Option func(*config)

func WithGormAllowGlobalUpdate

func WithGormAllowGlobalUpdate(allowGlobalUpdate bool) Option

WithGormAllowGlobalUpdate allows updates/deletes without WHERE conditions

func WithGormClauseBuilders

func WithGormClauseBuilders(clauseBuilders map[string]clause.ClauseBuilder) Option

WithGormClauseBuilders sets custom clause builders for SQL generation

func WithGormConnPool

func WithGormConnPool(connPool gorm.ConnPool) Option

WithGormConnPool sets a custom connection pool for GORM operations

func WithGormCreateBatchSize

func WithGormCreateBatchSize(createBatchSize int) Option

WithGormCreateBatchSize sets default batch size for bulk inserts

func WithGormDefaultContextTimeout

func WithGormDefaultContextTimeout(defaultContextTimeout time.Duration) Option

WithGormDefaultContextTimeout sets the default timeout for context in DB operations

func WithGormDefaultTransactionTimeout

func WithGormDefaultTransactionTimeout(defaultTransactionTimeout time.Duration) Option

WithGormDefaultTransactionTimeout sets the default timeout for transactions

func WithGormDisableAutomaticPing

func WithGormDisableAutomaticPing(disableAutomaticPing bool) Option

WithGormDisableAutomaticPing disables automatic database ping on initialization

func WithGormDisableForeignKeyConstraintWhenMigrating

func WithGormDisableForeignKeyConstraintWhenMigrating(disableForeignKeyConstraintWhenMigrating bool) Option

WithGormDisableForeignKeyConstraintWhenMigrating disables creating foreign key constraints during migrations

func WithGormDisableNestedTransaction

func WithGormDisableNestedTransaction(disableNestedTransaction bool) Option

WithGormDisableNestedTransaction disables nested transactions

func WithGormDryRun

func WithGormDryRun(dryRun bool) Option

WithGormDryRun enables generating SQL statements without executing them

func WithGormFullSaveAssociations

func WithGormFullSaveAssociations(fullSaveAssociations bool) Option

WithGormFullSaveAssociations enables saving all associations when saving a record

func WithGormIgnoreRelationshipsWhenMigrating

func WithGormIgnoreRelationshipsWhenMigrating(ignoreRelationshipsWhenMigrating bool) Option

WithGormIgnoreRelationshipsWhenMigrating disables saving relationships when performing migrations

func WithGormLogger

func WithGormLogger(logger loggerGorm.Interface) Option

WithGormLogger sets a custom logger for GORM

func WithGormNamingStrategy

func WithGormNamingStrategy(namingStrategy schema.Namer) Option

WithGormNamingStrategy sets a custom naming strategy for tables and columns

func WithGormNowFunc

func WithGormNowFunc(nowFunc func() time.Time) Option

WithGormNowFunc sets a custom function to generate timestamps for new records

func WithGormPlugins

func WithGormPlugins(plugins map[string]gorm.Plugin) Option

WithGormPlugins sets custom GORM plugins

func WithGormPrepareStmt

func WithGormPrepareStmt(prepareStmt bool) Option

WithGormPrepareStmt enables caching prepared statements for faster execution

func WithGormPrepareStmtMaxSize

func WithGormPrepareStmtMaxSize(prepareStmtMaxSize int) Option

WithGormPrepareStmtMaxSize sets the maximum size of the prepared statement cache

func WithGormPrepareStmtTTL

func WithGormPrepareStmtTTL(prepareStmtTTL time.Duration) Option

WithGormPrepareStmtTTL sets the TTL (time-to-live) for prepared statements in the cache

func WithGormPropagateUnscoped

func WithGormPropagateUnscoped(propagateUnscoped bool) Option

WithGormPropagateUnscoped propagates Unscoped mode to nested statements

func WithGormQueryFields

func WithGormQueryFields(queryFields bool) Option

WithGormQueryFields enables querying all fields of a table

func WithGormSkipDefaultTransaction

func WithGormSkipDefaultTransaction(skipDefaultTransaction bool) Option

WithGormSkipDefaultTransaction disables automatic transactions for single create/update/delete operations

func WithGormTranslateError

func WithGormTranslateError(translateError bool) Option

WithGormTranslateError enables translating database errors using Dialector

func WithPostgresConn

func WithPostgresConn(conn gorm.ConnPool) Option

WithPostgresConn sets a custom connection pool for Postgres (e.g., *sql.DB or sqlmock)

func WithPostgresDSN

func WithPostgresDSN(dsn string) Option

WithPostgresDSN sets the Data Source Name (connection string) for Postgres

func WithPostgresDriverName

func WithPostgresDriverName(driverName string) Option

WithPostgresDriverName sets the driver name for the Postgres Dialector

func WithPostgresPreferSimpleProtocol

func WithPostgresPreferSimpleProtocol(preferSimpleProtocol bool) Option

WithPostgresPreferSimpleProtocol enables Postgres simple protocol instead of extended protocol

func WithPostgresWithoutQuotingCheck

func WithPostgresWithoutQuotingCheck(withoutQuotingCheck bool) Option

WithPostgresWithoutQuotingCheck disables column/table quoting checks

func WithPostgresWithoutReturning

func WithPostgresWithoutReturning(withoutReturning bool) Option

WithPostgresWithoutReturning disables generating RETURNING clause in INSERT/UPDATE/DELETE

Jump to

Keyboard shortcuts

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