See this original community forums post
How can we create functions that determine which Roles a Key or Token has?
- Create a new Collection.
- Create one Document for each Role that uniquely represents each role.
- Create the required Indexes to read the new Collection.
- Update each Role with privileges to read the indexes, but a predicate that lets it only read the one specific Document that represents it.
Then, when you try to read the Indexes only those documents that the roles have access to will be read. You can interpret which documents are read as the roles that you have. And we can create Functions that make it easy to use this stuff.