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 operation Query cache Can be based on Database reverse generation code Cascading loading Provide sql statement log output Support batch query processing
gorm
hook mechanism (Before/After Create/Save/Update/Delete/Find) Object relationship Has One, Has Many, Belongs To, Many To Many, Polymorphism Hot loading Support native sql operations Transactional Chain apitx := db.Where("name = ?", "jinzhu").Where("age = ?", 20).Find(&users)Supported databases are: mysql, postgre, sqlite, sqlserver Query operation
gorose
Supported databases are: mysql, postgres, sqlite, mssql, oracle Chain api Connect multiple databases and switch simultaneously Support native sql operations Support batch query processing Transactionalsimilarity
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 processing xorm supports master-slave read and write separation gorm supports hot loading gorose facilitates switching between multiple databases Comprehensive 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!