This would give us quite a few benefits.
A new app always gets a dedicated database; very easy to deploy the same app multiple times in the same project without interfering with someone else.
We can write code like this (we already do this but you get the idea):
const DemoColl = context.services.get('mongodb-atlas').db(context.app.clientAppId).collection('Demo')
Even better would be to have the default database name as a context/placeholder value. Using %(%%environment.values.database)
is OK but a little error-prone in the deployment phase.
demoapp/data_sources/mongodb-atlas/%(%%environment.values.database)/Demo/rules.json
{
"collection": "Demo",
"database": "%(%%environment.values.database)",
"roles": [
{
"name": "default",
"apply_when": {},
"insert": true,
"delete": true,
"search": true,
"additional_fields": {}
}
]
}
Another thought is to combine database name with environment so there is 4 databases in the cluster:
demoapp-xijqb
(no environment)demoapp-xijqb-development
demoapp-xijqb-qa
demoapp-xijqb-production