forked from mirror/gorm
Add Take method, close #1228
This commit is contained in:
parent
cfd1cc586a
commit
fe3c94cd2d
7
main.go
7
main.go
|
@ -280,6 +280,13 @@ func (s *DB) First(out interface{}, where ...interface{}) *DB {
|
|||
inlineCondition(where...).callCallbacks(s.parent.callbacks.queries).db
|
||||
}
|
||||
|
||||
// Take return a record that match given conditions, the order will depend on the database implementation
|
||||
func (s *DB) Take(out interface{}, where ...interface{}) *DB {
|
||||
newScope := s.NewScope(out)
|
||||
newScope.Search.Limit(1)
|
||||
return newScope.inlineCondition(where...).callCallbacks(s.parent.callbacks.queries).db
|
||||
}
|
||||
|
||||
// Last find last record that match given conditions, order by primary key
|
||||
func (s *DB) Last(out interface{}, where ...interface{}) *DB {
|
||||
newScope := s.NewScope(out)
|
||||
|
|
Loading…
Reference in New Issue