client

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaskDSN added in v0.9.1

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

Types

type Option

type Option func(*config)

func WithGormAllowGlobalUpdate added in v0.2.0

func WithGormAllowGlobalUpdate(allowGlobalUpdate bool) Option

WithGormAllowGlobalUpdate allows updates/deletes without WHERE conditions

func WithGormClauseBuilders added in v0.2.0

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

WithGormClauseBuilders sets custom clause builders for SQL generation

func WithGormConnPool added in v0.2.0

func WithGormConnPool(connPool gorm.ConnPool) Option

WithGormConnPool sets a custom connection pool for GORM operations

func WithGormCreateBatchSize added in v0.2.0

func WithGormCreateBatchSize(createBatchSize int) Option

WithGormCreateBatchSize sets default batch size for bulk inserts

func WithGormDefaultContextTimeout added in v0.2.0

func WithGormDefaultContextTimeout(defaultContextTimeout time.Duration) Option

WithGormDefaultContextTimeout sets the default timeout for context in DB operations

func WithGormDefaultTransactionTimeout added in v0.2.0

func WithGormDefaultTransactionTimeout(defaultTransactionTimeout time.Duration) Option

WithGormDefaultTransactionTimeout sets the default timeout for transactions

func WithGormDisableAutomaticPing added in v0.2.0

func WithGormDisableAutomaticPing(disableAutomaticPing bool) Option

WithGormDisableAutomaticPing disables automatic database ping on initialization

func WithGormDisableForeignKeyConstraintWhenMigrating added in v0.2.0

func WithGormDisableForeignKeyConstraintWhenMigrating(disableForeignKeyConstraintWhenMigrating bool) Option

WithGormDisableForeignKeyConstraintWhenMigrating disables creating foreign key constraints during migrations

func WithGormDisableNestedTransaction added in v0.2.0

func WithGormDisableNestedTransaction(disableNestedTransaction bool) Option

WithGormDisableNestedTransaction disables nested transactions

func WithGormDryRun added in v0.2.0

func WithGormDryRun(dryRun bool) Option

WithGormDryRun enables generating SQL statements without executing them

func WithGormFullSaveAssociations added in v0.2.0

func WithGormFullSaveAssociations(fullSaveAssociations bool) Option

WithGormFullSaveAssociations enables saving all associations when saving a record

func WithGormIgnoreRelationshipsWhenMigrating added in v0.2.0

func WithGormIgnoreRelationshipsWhenMigrating(ignoreRelationshipsWhenMigrating bool) Option

WithGormIgnoreRelationshipsWhenMigrating disables saving relationships when performing migrations

func WithGormLogger added in v0.2.0

func WithGormLogger(logger loggerGorm.Interface) Option

WithGormLogger sets a custom logger for GORM

func WithGormNamingStrategy added in v0.2.0

func WithGormNamingStrategy(namingStrategy schema.Namer) Option

WithGormNamingStrategy sets a custom naming strategy for tables and columns

func WithGormNowFunc added in v0.2.0

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

WithGormNowFunc sets a custom function to generate timestamps for new records

func WithGormPlugins added in v0.2.0

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

WithGormPlugins sets custom GORM plugins

func WithGormPrepareStmt added in v0.2.0

func WithGormPrepareStmt(prepareStmt bool) Option

WithGormPrepareStmt enables caching prepared statements for faster execution

func WithGormPrepareStmtMaxSize added in v0.2.0

func WithGormPrepareStmtMaxSize(prepareStmtMaxSize int) Option

WithGormPrepareStmtMaxSize sets the maximum size of the prepared statement cache

func WithGormPrepareStmtTTL added in v0.2.0

func WithGormPrepareStmtTTL(prepareStmtTTL time.Duration) Option

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

func WithGormPropagateUnscoped added in v0.2.0

func WithGormPropagateUnscoped(propagateUnscoped bool) Option

WithGormPropagateUnscoped propagates Unscoped mode to nested statements

func WithGormQueryFields added in v0.2.0

func WithGormQueryFields(queryFields bool) Option

WithGormQueryFields enables querying all fields of a table

func WithGormSkipDefaultTransaction added in v0.2.0

func WithGormSkipDefaultTransaction(skipDefaultTransaction bool) Option

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

func WithGormTranslateError added in v0.2.0

func WithGormTranslateError(translateError bool) Option

WithGormTranslateError enables translating database errors using Dialector

func WithPostgresConn added in v0.2.0

func WithPostgresConn(conn gorm.ConnPool) Option

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

func WithPostgresDSN added in v0.2.0

func WithPostgresDSN(dsn string) Option

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

func WithPostgresDriverName added in v0.2.0

func WithPostgresDriverName(driverName string) Option

WithPostgresDriverName sets the driver name for the Postgres Dialector

func WithPostgresPreferSimpleProtocol added in v0.2.0

func WithPostgresPreferSimpleProtocol(preferSimpleProtocol bool) Option

WithPostgresPreferSimpleProtocol enables Postgres simple protocol instead of extended protocol

func WithPostgresWithoutQuotingCheck added in v0.2.0

func WithPostgresWithoutQuotingCheck(withoutQuotingCheck bool) Option

WithPostgresWithoutQuotingCheck disables column/table quoting checks

func WithPostgresWithoutReturning added in v0.2.0

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