Create Sequelize with existing connection

Viewed 195

I am facing issue with Database connection pool with serverless lambda, it is creating new connection pool each time when starting container. So, if there were 5 lambda functions executing sequentially, there will be 5 connection pools getting created which isn't necessary. So i am thinking to have 1 lambda function to return a connection to other api lambda functions to utilize that connection instead of creating new connection pool. (Suggestions accepted to improvise this solution also.)

I am using Sequelize in my project, just wondering if there is way to create Sequelize with an exiting connection object like below

var sequelize = new Sequelize({
connection: Connection-object #From another lambda function.
});

Or is there a way to execute query in another lambda function and map it to model in Sequelize.

0 Answers
Related