Add expansion for database and collection in Rules Expressions
In a rule expression, in addition to expansions such as %%user and %%request, it would be very useful to have an expansion variable for the database and collection. This would allow granting or blocking access to the data based on which database or collection is queried.
For example, in a multi-tenant application, users authenticate with a JWT token which contains an ID that identifies which data they can access. Currently, we can only check the ID against an element in documents so we have to put that ID in every document. Each collection contains data from a single ID, so it requires to have the same ID in every element of the collection. This is inefficient, it increases the data storage and transfer.
Instead of this rule expression
{
"tenantid": "%%user.data.tenantid"
}
we could have
{
"%%collection.name": "%%user.data.tenant_id"
}