N
N
Nikita2020-12-12 20:33:45
MongoDB
Nikita, 2020-12-12 20:33:45

How to connect multiple mongo db in node.js?

Tell me how can I connect two MongoDB databases in a node.js project?

A small explanation of what this is for:
Now there are two ready-made, working sites on node. The task is to make another one that would use a collection of users from the database of the first site and a collection with some data from the database of the second site. (When registering on a new site, the user must be saved in the database and be available for authorization on the first site)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuriy Vorobyov, 2020-12-13
@nikitabaks

You can use mongoose . The result will be something like this:

const mongoose = require('mongoose');

const firstConnection = mongoose.createConnection('опции для подключения')
const secondfirstConnection = mongoose.createConnection('опции для подключения')

You can read more about multiple connections here .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question