Nodejs MySQL pool connection advice to many companies databases

80
July 27, 2022, at 6:40 PM

I have an web app that wil be accessed by multiples companies.

I use, in my backend, a node API accessing MySQL databases with mysql2 lib.

Each company has your owner database.

I have an account database to save info about each company and which is your database name.

On backend, I use node express and a middleware to identify each company by your URL. With the url I can query the account database and I get the correct database name to each company.

After that, I can check if the company has a connection pool. Otherwise, I create or not a connection pool to the company(this is my doubt).

I have two options to pool:

  1. Create a single pool to all companies and change the database before acquire a db connection using mysql "changeUser" method.
  2. Create a pool to each company and there is no need to use "changeUser"

For now, I have 5 companies, but this amount will increase at soon.

What option pool will be better to future when I have more companies accessing the app?

Rent Charter Buses Company
READ ALSO
How to create a url that opens a tab downloads a file and closes the tab

How to create a url that opens a tab downloads a file and closes the tab

I want to create an URL that when clicked upon opens a tab, downloads a file, and closes that tabDo you guys know how to do it? Following is an example: https://cdn

106
Waiting for download to complete on Puppeteer

Waiting for download to complete on Puppeteer

I have a script made using nodejs and puppeteer which downloads a file from a button (which doesn't redirect to a url), so right now i'm using await await page

113
Why is my signed XML getting rejected by authorization?

Why is my signed XML getting rejected by authorization?

I'm trying to create a signed XML post requestThe XML needs to be sent in the body of the request

80
What library can I use to generate random mock data based on Open API spec inside a node application?

What library can I use to generate random mock data based on Open API spec inside a node application?

I am looking for a library which would generate a mock data based on openapi spec (client side only)So the idea is not to have a separate local server, as it's done in openapi-mock-express-middleware, but rather have data to be generated on fly inside...

66