Adding new collection to each DB in a multinenancy deployment? Issues

Hello, I am working in a multinenancy approach with 1 MongoDB database per client (up to 1000 potential clients). We have created the scripts to create each new customer environment with all the collections needed in the datamodel.

The problem comes when trying to create a procedure to add a new collection with scheme to all the clients (to make possible to expand the software functionality with new features needed additional data collections).

NodeJS is not managing properly establishing connections and waiting from MongoDB the creation of new collection to close the connection and open the new ones. The Promise mechanism is not working properly.

Anyone with experience in this type of massive db datamodel updates could provide a clue.

thanks in advance.

Be aware of Massive Number of Collections | MongoDB

Most likely is the issue is from your code. Please share.

You are not supposed to open and close the connections frequently.