Home > Article > Backend Development > Does golang require ORM?
The currently more mainstream/active ORMs include gorm, xorm, gorose, etc. (Recommended learning: go)
xorm
has, err := engine.Where("name = ?", name).Desc("id").Get(&user) err := engine.Where(builder.NotIn("a", 1, 2).And(builder.In("b", "c", "d", "e"))).Find(&users)Support native sql operationQuery cacheCan be based on Database reverse generation codeCascading loadingProvide sql statement log outputSupport batch query processing
gorm
hook mechanism (Before/After Create/Save/Update/Delete/Find)Object relationship Has One, Has Many, Belongs To, Many To Many, PolymorphismHot loading Support native sql operationsTransactionalChain apitx := db.Where("name = ?", "jinzhu").Where("age = ?", 20).Find(&users)Supported databases are: mysql, postgre, sqlite, sqlserverQuery operation
gorose
Supported databases are: mysql, postgres, sqlite, mssql, oracleChain apiConnect multiple databases and switch simultaneouslySupport native sql operationsSupport batch query processingTransactionalsimilarity
The databases supported by each ORM are basically the same (all mainstream databases support it)Support transactional, chained queries, etc.Differences
xorm and gorose support batch query processingxorm supports master-slave read and write separationgorm supports hot loadinggorose facilitates switching between multiple databasesComprehensive documentation gorm>xorm>goroseThe above is the detailed content of Does golang require ORM?. For more information, please follow other related articles on the PHP Chinese website!