Take finds the first record returned by the database in no specified order, matching given conditions conds
(dest interface{}, conds ...interface{})
| 143 | |
| 144 | // Take finds the first record returned by the database in no specified order, matching given conditions conds |
| 145 | func (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 |
| 158 | func (db *DB) Last(dest interface{}, conds ...interface{}) (tx *DB) { |
nothing calls this directly
no test coverage detected