Cached connections

Hi all,
I am working on the backend project and need to cache the connection. Is there a way to connect to MongoDB using mongoose but select the database name dynamically?

maybe you could write a function that returns a string based on db criteria then use a template string to construct the new db string

// example
let whichDB(criteria) = () => {
    switch(criteria):
        case 'some_criteria':
            return 'db1' 
            break;
        default:
            return 'db0'
}
let mongo_uri = `https://your.mongodb.uri/${whichDB('some_criteria')}`