Skip to content

Commit

Permalink
Merge pull request go-gorm#5043 from Saurabh-Thakre/patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee authored Feb 4, 2022
2 parents f19b84d + 581a879 commit 93b1a6f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion finisher_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func (tx *DB) assignInterfacesToValue(values ...interface{}) {
}
}
}

// FirstOrInit gets the first matched record or initialize a new instance with given conditions (only works with struct or map conditions)
func (db *DB) FirstOrInit(dest interface{}, conds ...interface{}) (tx *DB) {
queryTx := db.Limit(1).Order(clause.OrderByColumn{
Column: clause.Column{Table: clause.CurrentTable, Name: clause.PrimaryKey},
Expand All @@ -281,6 +281,7 @@ func (db *DB) FirstOrInit(dest interface{}, conds ...interface{}) (tx *DB) {
return
}

// FirstOrCreate gets the first matched record or create a new one with given conditions (only works with struct, map conditions)
func (db *DB) FirstOrCreate(dest interface{}, conds ...interface{}) (tx *DB) {
queryTx := db.Limit(1).Order(clause.OrderByColumn{
Column: clause.Column{Table: clause.CurrentTable, Name: clause.PrimaryKey},
Expand Down

0 comments on commit 93b1a6f

Please sign in to comment.