alex-ppg / fastify-mongoose

A Fastify plugin to connect to a MongoDB instance via the Mongoose ODM
GNU General Public License v3.0
15 stars 7 forks source link

Mutiple Databases #2

Open johntom opened 5 years ago

johntom commented 5 years ago

I need to convert a repo that uses 2 mongodb databases and 1 mySql database. How to accomplist the first goal of attaching to the mondodb databases and assinging the models?

Eomm commented 4 years ago

I did some analysis for this here: https://stackoverflow.com/a/62571109/3309466

It is doable using const conn = mongoose.createConnection( instead of connect here:

https://github.com/alex-ppg/fastify-mongoose/blob/3ca860ae03eaf4191ab70c2b4763492c85cfbadc/index.js#L59

Using a connection singleton break the encapsulation of fastify so it would be a simple but huge improvements