Using two connections with Mongodb using Mongoose with references to distinct collections

Asked

Viewed 98 times

0

I have two Mongodb databases that I connect using Mongoose on Nodejs, one with an X collection that references the ID of another Y collection that is in another Mongodb database on another server.

I need to unify the two databases by copying the X collection according to certain criteria for the database containing the Y collection. Keeping the X collection data up to date on both database servers.

How can I transport a Model from one connection to another?

  • You want to import data from one database to another or use it simultaneously?

  • both, both import in order to keep the second updated, when use simultaneously, since in bank 1 will not have the collections Y.

  • You have two separate servers? You can use the tools like mongodump to save the documents in one file and then import it to the other server using mongorestore.

  • as I said in the question, there are criteria to be considered. And this will be at runtime.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.