MCPcopy
hub / github.com/go-gorm/gorm / Group

Method Group

chainable_api.go:283–291  ·  view source on GitHub ↗

Group specify the group method on the find // Select the sum age of users with given names db.Model(&User{}).Select("name, sum(age) as total").Group("name").Find(&results)

(name string)

Source from the content-addressed store, hash-verified

281// // Select the sum age of users with given names
282// db.Model(&User{}).Select("name, sum(age) as total").Group("name").Find(&results)
283func (db *DB) Group(name string) (tx *DB) {
284 tx = db.getInstance()
285
286 fields := strings.FieldsFunc(name, utils.IsInvalidDBNameChar)
287 tx.Statement.AddClause(clause.GroupBy{
288 Columns: []clause.Column{{Name: name, Raw: len(fields) != 1}},
289 })
290 return
291}
292
293// Having specify HAVING conditions for GROUP BY
294//

Callers

nothing calls this directly

Calls 2

getInstanceMethod · 0.95
AddClauseMethod · 0.80

Tested by

no test coverage detected