We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0e33b28 commit 97d6fc6Copy full SHA for 97d6fc6
models/user.go
@@ -236,12 +236,18 @@ func (u *User) GetEmail() string {
236
return u.Email
237
}
238
239
+
240
+type AllUsersOpts struct {
241
+ AdminsOnly bool
242
+}
243
244
// GetAllUsers returns a slice of all users found in DB.
-func GetAllUsers() ([]*User, error) {
245
+func GetAllUsers(opts AllUsersOpts) ([]*User, error) {
246
users := make([]*User, 0)
- return users, x.OrderBy("id").Find(&users)
247
+ return users, x.OrderBy("id").Where("is_admin = ?", opts.AdminsOnly).Find(&users)
248
249
250
251
// APIFormat converts a User to api.User
252
func (u *User) APIFormat() *api.User {
253
if u == nil {
0 commit comments