Skip to content

Commit 97d6fc6

Browse files
ydelafollyeadelowo
andauthored
Update models/user.go
Co-authored-by: Lanre Adelowo <[email protected]>
1 parent 0e33b28 commit 97d6fc6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

models/user.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,18 @@ func (u *User) GetEmail() string {
236236
return u.Email
237237
}
238238

239+
240+
type AllUsersOpts struct {
241+
AdminsOnly bool
242+
}
243+
239244
// GetAllUsers returns a slice of all users found in DB.
240-
func GetAllUsers() ([]*User, error) {
245+
func GetAllUsers(opts AllUsersOpts) ([]*User, error) {
241246
users := make([]*User, 0)
242-
return users, x.OrderBy("id").Find(&users)
247+
return users, x.OrderBy("id").Where("is_admin = ?", opts.AdminsOnly).Find(&users)
243248
}
244249

250+
245251
// APIFormat converts a User to api.User
246252
func (u *User) APIFormat() *api.User {
247253
if u == nil {

0 commit comments

Comments
 (0)