Categorygithub.com/jinzhu/gorm
modulepackage
1.9.16
Repository: https://github.com/jinzhu/gorm.git
Documentation: pkg.go.dev

# README

GORM

GORM V2 moved to https://github.com/go-gorm/gorm

GORM V1 Doc https://v1.gorm.io/

# Packages

No description provided by the author

# Functions

AddNamingStrategy sets the naming strategy.
Expr generate raw SQL expression, for example: DB.Model(&product).Update("price", gorm.Expr("price * ? + ?", 2, 100)).
GetDialect gets the dialect for the specified dialect name.
IsByteArrayOrSlice returns true of the reflected value is an array or slice.
IsRecordNotFoundError returns true if error contains a RecordNotFound error.
Open initialize a new db connection, need to import driver first, e.g: import _ "github.com/go-sql-driver/mysql" func main() { db, err := gorm.Open("mysql", "user:password@/dbname?charset=utf8&parseTime=True&loc=Local") } GORM has wrapped some drivers, for easier to remember driver's import path, so you could import the mysql driver with import _ "github.com/jinzhu/gorm/dialects/mysql" // import _ "github.com/jinzhu/gorm/dialects/postgres" // import _ "github.com/jinzhu/gorm/dialects/sqlite" // import _ "github.com/jinzhu/gorm/dialects/mssql".
RegisterDialect register new dialect.
ToColumnName convert string to db name.
ToDBName convert string to db name.
ToTableName convert string to table name.

# Variables

DefaultCallback default callbacks defined by gorm.
DefaultTableNameHandler default table name handler.
ErrCantStartTransaction can't start transaction when you are trying to start one with `Begin`.
ErrInvalidSQL occurs when you attempt a query with invalid SQL.
ErrInvalidTransaction occurs when you are trying to `Commit` or `Rollback`.
ErrRecordNotFound returns a "record not found error".
ErrUnaddressable unaddressable value.
No description provided by the author
NowFunc returns current time, this function is exported in order to be able to give the flexibility to the developer to customize it according to their needs, e.g: gorm.NowFunc = func() time.Time { return time.Now().UTC() }.
ParseFieldStructForDialect get field's sql data type.
TheNamingStrategy is being initialized with defaultNamingStrategy.

# Structs

Association Mode contains some helper methods to handle relationship things easily.
Callback is a struct that contains all CRUD callbacks Field `creates` contains callbacks will be call when creating object Field `updates` contains callbacks will be call when updating object Field `deletes` contains callbacks will be call when deleting object Field `queries` contains callbacks will be call when querying object with query methods like Find, First, Related, Association..
CallbackProcessor contains callback informations.
DB contains information for current db connection.
DefaultForeignKeyNamer contains the default foreign key name generator method.
Field model field definition.
JoinTableForeignKey join table foreign key struct.
JoinTableHandler default join table handler.
JoinTableSource is a struct that contains model type and foreign keys.
Logger default logger.
Model base model definition, including fields `ID`, `CreatedAt`, `UpdatedAt`, `DeletedAt`, which could be embedded in your models type User struct { gorm.Model }.
ModelStruct model definition.
NamingStrategy represents naming strategies.
Relationship described the relationship between models.
No description provided by the author
No description provided by the author
Scope contain current operation's information when you perform any operation on the database.
SQL expression.
StructField model field's struct definition.

# Interfaces

Dialect interface contains behaviors that differ across SQL database.
JoinTableHandlerInterface is an interface for how to handle many2many relations.
LogWriter log writer interface.
SQLCommon is the minimal database connection functionality gorm requires.

# Type aliases

Errors contains all happened errors.
Namer is a function type which is given a string and return a string.