GetUserByID returns the user by the given id or nil.
(id uint)
| 20 | |
| 21 | // GetUserByID returns the user by the given id or nil. |
| 22 | func (d *GormDatabase) GetUserByID(id uint) (*model.User, error) { |
| 23 | user := new(model.User) |
| 24 | err := d.DB.Find(user, id).Error |
| 25 | if err == gorm.ErrRecordNotFound { |
| 26 | err = nil |
| 27 | } |
| 28 | if user.ID == id { |
| 29 | return user, err |
| 30 | } |
| 31 | return nil, err |
| 32 | } |
| 33 | |
| 34 | // CountUser returns the user count which satisfies the given condition. |
| 35 | func (d *GormDatabase) CountUser(condition ...interface{}) (int64, error) { |
nothing calls this directly
no outgoing calls
no test coverage detected