GORM is a comprehensive Object-Relational Mapping library for Go that prioritizes developer experience and ease of use. The library provides a full-featured ORM solution designed to streamline database interactions in Go applications, offering extensive functionality for managing relational data through Go structs and methods rather than raw SQL.
The core capabilities of GORM encompass a wide range of database operations and patterns. The library supports multiple association types including Has One, Has Many, Belongs To, Many To Many relationships, along with polymorphism and single-table inheritance patterns. It includes a comprehensive hooks system with Before and After triggers for Create, Save, Update, Delete, and Find operations, allowing developers to inject custom logic at various points in the data lifecycle. Transaction support extends beyond basic transactions to include nested transactions, save points, and the ability to rollback to specific saved points, providing fine-grained control over data consistency.
GORM's query capabilities are extensive, featuring eager loading through Preload and Joins methods, batch operations including batch insert and FindInBatches, and the ability to find results mapped to custom structures. The library includes a SQL builder for constructing complex queries programmatically, with support for upsert operations, row locking, optimizer hints, index hints, comment hints, named arguments, and SQL expressions within search, update, and create operations. Additional features include support for composite primary keys, automatic migrations, built-in logging, and context support for managing request lifecycles.
The architecture emphasizes extensibility through a flexible plugin API. The Database Resolver plugin enables multiple database connections and read/write splitting patterns, while Prometheus integration provides monitoring capabilities. The library also supports prepared statement mode and dry-run mode for query inspection and debugging.
According to GitGenius activity tracking, the repository shows significant maintenance and community engagement.
GORM is released under the MIT License and maintains comprehensive test coverage across all features. The project is supported by official documentation at gorm.io and includes a code generation tool called Gen for type-safe query building. The library's emphasis on being developer-friendly is reflected in its intuitive API design and extensive documentation resources available to users.