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

Method Take

finisher_api.go:145–155  ·  view source on GitHub ↗

Take finds the first record returned by the database in no specified order, matching given conditions conds

(dest interface{}, conds ...interface{})

Source from the content-addressed store, hash-verified

143
144// Take finds the first record returned by the database in no specified order, matching given conditions conds
145func (db *DB) Take(dest interface{}, conds ...interface{}) (tx *DB) {
146 tx = db.Limit(1)
147 if len(conds) > 0 {
148 if exprs := tx.Statement.BuildCondition(conds[0], conds[1:]...); len(exprs) > 0 {
149 tx.Statement.AddClause(clause.Where{Exprs: exprs})
150 }
151 }
152 tx.Statement.RaiseErrorOnNotFound = true
153 tx.Statement.Dest = dest
154 return tx.callbacks.Query().Execute(tx)
155}
156
157// Last finds the last record ordered by primary key, matching given conditions conds
158func (db *DB) Last(dest interface{}, conds ...interface{}) (tx *DB) {

Callers

nothing calls this directly

Calls 5

LimitMethod · 0.95
BuildConditionMethod · 0.80
AddClauseMethod · 0.80
ExecuteMethod · 0.80
QueryMethod · 0.80

Tested by

no test coverage detected