From 581a879bf1ff1af7fcb361f0c6e4b201dbed75f0 Mon Sep 17 00:00:00 2001 From: Saurabh Thakre Date: Mon, 31 Jan 2022 17:26:28 +0530 Subject: [PATCH] Added comments to existing methods Added two comments to describe FirstOrInit and FirstOrCreate methods. --- finisher_api.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/finisher_api.go b/finisher_api.go index cbbd48cb..3a179977 100644 --- a/finisher_api.go +++ b/finisher_api.go @@ -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}, @@ -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},