MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / AllPrincipalIDs

Method AllPrincipalIDs

db/database.go:1052–1079  ·  view source on GitHub ↗

Returns the IDs of all users and roles, including deleted Roles

(ctx context.Context)

Source from the content-addressed store, hash-verified

1050
1051// Returns the IDs of all users and roles, including deleted Roles
1052func (db *DatabaseContext) AllPrincipalIDs(ctx context.Context) (users, roles []string, err error) {
1053
1054 if db.UseLegacySyncDocsIndex() || db.Options.UseViews {
1055 return db.getAllPrincipalIDsSyncDocs(ctx)
1056 }
1057
1058 wg := sync.WaitGroup{}
1059 wg.Add(2)
1060 var getUsersErr error
1061 go func() {
1062 defer wg.Done()
1063 users, getUsersErr = db.GetUserNames(ctx)
1064 }()
1065 var getRolesErr error
1066 go func() {
1067 defer wg.Done()
1068 includeDeleted := true
1069 roles, getRolesErr = db.getRoleIDsUsingIndex(ctx, includeDeleted)
1070 }()
1071 wg.Wait()
1072 if getUsersErr != nil {
1073 return nil, nil, getUsersErr
1074 }
1075 if getRolesErr != nil {
1076 return nil, nil, getRolesErr
1077 }
1078 return users, roles, err
1079}
1080
1081// Returns the Names of all users
1082func (db *DatabaseContext) GetUserNames(ctx context.Context) (users []string, err error) {

Callers 6

GetRoleIDsMethod · 0.95
getUsersMethod · 0.80
allPrincipalIDsMethod · 0.80
TestGetRoleIDsFunction · 0.80
TestAllPrincipalIDsFunction · 0.80

Calls 7

GetUserNamesMethod · 0.95
getRoleIDsUsingIndexMethod · 0.95
DoneMethod · 0.80
AddMethod · 0.45
WaitMethod · 0.45

Tested by 2

TestGetRoleIDsFunction · 0.64
TestAllPrincipalIDsFunction · 0.64