This repository was archived by the owner on Jul 11, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Expand file tree Collapse file tree 1 file changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ export async function getAllUserSnaps() {
38
38
*
39
39
* @param {firestore.DocumentReference } associationRef Self descriptive
40
40
*/
41
- export async function getAllAssociationUsersSnaps ( associationRef ) {
41
+ export async function getAllAssociationUsersDocs ( associationRef ) {
42
42
const rolesQuery = await getAssociationRolesRef ( associationRef . id ) . get ( ) ;
43
43
const usersDocs = [ ] ;
44
44
rolesQuery . forEach ( async roleDoc => {
@@ -54,6 +54,33 @@ export async function getAllAssociationUsersSnaps(associationRef) {
54
54
return usersDocs ;
55
55
}
56
56
57
+ /**
58
+ * Fetches all users that belongs to the provided association
59
+ *
60
+ * @param {firestore.DocumentReference } associationRef Self descriptive
61
+ */
62
+ export async function getAllAssociationUsersDocsWithRoles ( associationRef ) {
63
+ const rolesQuery = await getAssociationRolesRef ( associationRef . id ) . get ( ) ;
64
+ const usersWithRoles = [ ] ;
65
+
66
+ rolesQuery . forEach ( async roleDoc => {
67
+ const usersQuery = await usersRef ( )
68
+ . where ( "associations" , "array-contains" , {
69
+ associationRef,
70
+ roleRef : roleDoc . ref
71
+ } )
72
+ . get ( ) ;
73
+ usersQuery . forEach ( userDoc =>
74
+ usersWithRoles . push ( {
75
+ userDoc : userDoc ,
76
+ roleDoc
77
+ } )
78
+ ) ;
79
+ } ) ;
80
+
81
+ return usersWithRoles ;
82
+ }
83
+
57
84
/**
58
85
* Fetches a user document
59
86
*
You can’t perform that action at this time.
0 commit comments