1

I have a developer that says Node JS can only connect to multiple databases on the same server. I would like her to be able to connect to MongoDB and mySQL at the same time ... Is it possible? And can you either provide some example code or point me to the proper documentation to do so? Thx!

2
  • 2
    It's difficult to even imagine what the developer may be thinking, to come to this conclusion. It honestly seems too straightforward for there to even exist documentation on how to do it -- you just write the code to connect to one, then write the code to connect to the other, then use those connections as needed. Using both is no different than only using one or the other. Did she say why she believes otherwise, or in what sense it wouldn't work? (Since they don't use the same library, they shouldn't interact negatively at all.) Can you get any more info/clarification on this? Jan 17, 2019 at 3:46
  • Thanks, Michael ... this is as I suspected. She knows that you can conenct to two databases but thinks they need to be the same kind of DB ... both MongoDB for example.
    – OregonDean
    Jan 17, 2019 at 16:31

1 Answer 1

2

As Michael said, you can do it by asynchronously connecting to the two databases. Node.js has non-blocking async I/O, which means that you can perform operations on the MongoDB database without waiting for other operations to finish running (and vice versa). You can read more on this here, and in the mongoose and mysql docs.

2
  • Thanks, Itai for the async information, we are using the databases independently so this is exactly our situation.
    – OregonDean
    Jan 17, 2019 at 16:33
  • If my answer answered your question feel free to mark it as approved :) Jan 17, 2019 at 16:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .