1
0

Added pagination (#16)

This commit is contained in:
konrad
2018-11-09 10:30:17 +00:00
committed by Gitea
parent 0e7e1b7e38
commit d232836423
22 changed files with 71 additions and 31 deletions

View File

@ -1,7 +1,7 @@
package models
// ReadAll gets all users who have access to a namespace
func (un *NamespaceUser) ReadAll(u *User) (interface{}, error) {
func (un *NamespaceUser) ReadAll(u *User, page int) (interface{}, error) {
// Check if the user has access to the namespace
l, err := GetNamespaceByID(un.NamespaceID)
if err != nil {
@ -16,6 +16,7 @@ func (un *NamespaceUser) ReadAll(u *User) (interface{}, error) {
err = x.
Join("INNER", "users_namespace", "user_id = users.id").
Where("users_namespace.namespace_id = ?", un.NamespaceID).
Limit(getLimitFromPageIndex(page)).
Find(&all)
return all, err