Documentation
¶
Index ¶
- func MaskDSN(raw string) string
- func New(opts ...Option) (*gorm.DB, error)
- type Option
- func WithGormAllowGlobalUpdate(allowGlobalUpdate bool) Option
- func WithGormClauseBuilders(clauseBuilders map[string]clause.ClauseBuilder) Option
- func WithGormConnPool(connPool gorm.ConnPool) Option
- func WithGormCreateBatchSize(createBatchSize int) Option
- func WithGormDefaultContextTimeout(defaultContextTimeout time.Duration) Option
- func WithGormDefaultTransactionTimeout(defaultTransactionTimeout time.Duration) Option
- func WithGormDisableAutomaticPing(disableAutomaticPing bool) Option
- func WithGormDisableForeignKeyConstraintWhenMigrating(disableForeignKeyConstraintWhenMigrating bool) Option
- func WithGormDisableNestedTransaction(disableNestedTransaction bool) Option
- func WithGormDryRun(dryRun bool) Option
- func WithGormFullSaveAssociations(fullSaveAssociations bool) Option
- func WithGormIgnoreRelationshipsWhenMigrating(ignoreRelationshipsWhenMigrating bool) Option
- func WithGormLogger(logger loggerGorm.Interface) Option
- func WithGormNamingStrategy(namingStrategy schema.Namer) Option
- func WithGormNowFunc(nowFunc func() time.Time) Option
- func WithGormPlugins(plugins map[string]gorm.Plugin) Option
- func WithGormPrepareStmt(prepareStmt bool) Option
- func WithGormPrepareStmtMaxSize(prepareStmtMaxSize int) Option
- func WithGormPrepareStmtTTL(prepareStmtTTL time.Duration) Option
- func WithGormPropagateUnscoped(propagateUnscoped bool) Option
- func WithGormQueryFields(queryFields bool) Option
- func WithGormSkipDefaultTransaction(skipDefaultTransaction bool) Option
- func WithGormTranslateError(translateError bool) Option
- func WithPostgresConn(conn gorm.ConnPool) Option
- func WithPostgresDSN(dsn string) Option
- func WithPostgresDriverName(driverName string) Option
- func WithPostgresPreferSimpleProtocol(preferSimpleProtocol bool) Option
- func WithPostgresWithoutQuotingCheck(withoutQuotingCheck bool) Option
- func WithPostgresWithoutReturning(withoutReturning bool) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MaskDSN ¶
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.
Types ¶
type Option ¶
type Option func(*config)
func WithGormAllowGlobalUpdate ¶
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 ¶
WithGormConnPool sets a custom connection pool for GORM operations
func WithGormCreateBatchSize ¶
WithGormCreateBatchSize sets default batch size for bulk inserts
func WithGormDefaultContextTimeout ¶
WithGormDefaultContextTimeout sets the default timeout for context in DB operations
func WithGormDefaultTransactionTimeout ¶
WithGormDefaultTransactionTimeout sets the default timeout for transactions
func WithGormDisableAutomaticPing ¶
WithGormDisableAutomaticPing disables automatic database ping on initialization
func WithGormDisableForeignKeyConstraintWhenMigrating ¶
func WithGormDisableForeignKeyConstraintWhenMigrating(disableForeignKeyConstraintWhenMigrating bool) Option
WithGormDisableForeignKeyConstraintWhenMigrating disables creating foreign key constraints during migrations
func WithGormDisableNestedTransaction ¶
WithGormDisableNestedTransaction disables nested transactions
func WithGormDryRun ¶
WithGormDryRun enables generating SQL statements without executing them
func WithGormFullSaveAssociations ¶
WithGormFullSaveAssociations enables saving all associations when saving a record
func WithGormIgnoreRelationshipsWhenMigrating ¶
WithGormIgnoreRelationshipsWhenMigrating disables saving relationships when performing migrations
func WithGormLogger ¶
func WithGormLogger(logger loggerGorm.Interface) Option
WithGormLogger sets a custom logger for GORM
func WithGormNamingStrategy ¶
WithGormNamingStrategy sets a custom naming strategy for tables and columns
func WithGormNowFunc ¶
WithGormNowFunc sets a custom function to generate timestamps for new records
func WithGormPlugins ¶
WithGormPlugins sets custom GORM plugins
func WithGormPrepareStmt ¶
WithGormPrepareStmt enables caching prepared statements for faster execution
func WithGormPrepareStmtMaxSize ¶
WithGormPrepareStmtMaxSize sets the maximum size of the prepared statement cache
func WithGormPrepareStmtTTL ¶
WithGormPrepareStmtTTL sets the TTL (time-to-live) for prepared statements in the cache
func WithGormPropagateUnscoped ¶
WithGormPropagateUnscoped propagates Unscoped mode to nested statements
func WithGormQueryFields ¶
WithGormQueryFields enables querying all fields of a table
func WithGormSkipDefaultTransaction ¶
WithGormSkipDefaultTransaction disables automatic transactions for single create/update/delete operations
func WithGormTranslateError ¶
WithGormTranslateError enables translating database errors using Dialector
func WithPostgresConn ¶
WithPostgresConn sets a custom connection pool for Postgres (e.g., *sql.DB or sqlmock)
func WithPostgresDSN ¶
WithPostgresDSN sets the Data Source Name (connection string) for Postgres
func WithPostgresDriverName ¶
WithPostgresDriverName sets the driver name for the Postgres Dialector
func WithPostgresPreferSimpleProtocol ¶
WithPostgresPreferSimpleProtocol enables Postgres simple protocol instead of extended protocol
func WithPostgresWithoutQuotingCheck ¶
WithPostgresWithoutQuotingCheck disables column/table quoting checks
func WithPostgresWithoutReturning ¶
WithPostgresWithoutReturning disables generating RETURNING clause in INSERT/UPDATE/DELETE