gorm

Contents

Roadmap info from roadmap website

Gorm

The GORM is fantastic ORM library for Golang, aims to be developer friendly. It is an ORM library for dealing with relational databases. This gorm library is developed on the top of database/sql package. The overview and feature of ORM are: Full-Featured ORM (almost)

Visit the following resources to learn more:

Config

ParameterTypeDefaultDescription
SkipDefaultTransactionboolfalseSkip wrapping operations in a transaction by default, can improve performance but may lead to inconsistent data in case of failure.
NamingStrategystructnilCustomize table, column, and index naming conventions (you can define how names are generated).
FullSaveAssociationsboolfalseWhen saving an object, update its associations even if their foreign keys are already set. May result in unnecessary queries.
LoggerstructnilCustomize the logger to output GORM logs. If nil, GORM uses a default logger.
NowFuncfuncnilDefine a custom function to get the current time. Useful for overriding the time function used by GORM.
DryRunboolfalseIf true, GORM will generate SQL statements without executing them, useful for debugging or testing.
PrepareStmtboolfalsePrepares SQL statements to increase performance, but uses more memory.
DisableAutomaticPingboolfalseIf true, disables automatic Ping on the database connection, which is used to check if the connection is alive.
DisableForeignKeyConstraintWhenMigratingboolfalseDisable foreign key constraints in migrations (GORM automatically adds foreign key constraints when migrating).
IgnoreRelationshipsWhenMigratingboolfalseIf true, GORM will ignore relationships during migration. Useful for simplifying migrations but at the cost of data integrity enforcement.
DisableNestedTransactionboolfalseDisable nested transactions, as some databases (like SQLite) do not support it well.
AllowGlobalUpdateboolfalseIf true, allows global update/delete without a WHERE clause. This can be dangerous and should generally be avoided.
QueryFieldsboolfalseWhen true, GORM will use the exact SQL field names when generating queries instead of using aliases.
CreateBatchSizeint0Defines the batch size for insert operations. A value of 0 disables batching.
TranslateErrorboolfalseIf true, translates errors to be more meaningful or database-specific.
PropagateUnscopedboolfalseIf true, unscoped operations (e.g., ignoring soft deletes) are propagated to all related models.
ClauseBuildersmapnilCustom clause builders for GORM’s query generation. This allows overriding how GORM builds certain SQL clauses.
ConnPoolstructnilProvides a custom connection pool for GORM. You can define your own database connection handling.
DialectorstructnilCustomizes the database dialect (SQL variant). If nil, GORM uses the default dialect (e.g., SQLite, PostgreSQL, etc.).
Plugins[]interface{}nilAllows you to register custom plugins for extending GORM’s behavior.
#ready #online #reviewed #summary #informatic #database #packages #orm #databases #go