mirror of
https://github.com/vale981/Vulcan
synced 2025-03-05 09:31:43 -05:00
Merge pull request #1853 from justinr1234/check-on-count
Respect checkAccess for total resolver
This commit is contained in:
commit
cf05aedddc
1 changed files with 9 additions and 3 deletions
|
@ -135,10 +135,16 @@ export const getDefaultResolvers = (collectionName, resolverOptions = defaultOpt
|
|||
|
||||
const { selector } = await collection.getParameters(terms, {}, context);
|
||||
|
||||
return collection.find(selector).count();
|
||||
},
|
||||
const docs = collection.find(selector);
|
||||
|
||||
}
|
||||
// if collection has a checkAccess function defined, remove any documents that doesn't pass the check
|
||||
if (collection.checkAccess) {
|
||||
const { currentUser } = context;
|
||||
return docs.fetch().filter(doc => collection.checkAccess(currentUser, doc)).length;
|
||||
}
|
||||
|
||||
return docs.count();
|
||||
},
|
||||
}
|
||||
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue