How does mongodb transfer data between two tables

  node.js, question

How should data from one table be transferred to another table in mongodb? Please, not stint, thank you first.

Under the same Mongodb instance:

use db_source;
 var docs = db_source.collection_souce.find();
 use db_target;

Between different Mongodb instances

Mongodump and mongorestore can be used.


mongodump -h host:port -d db_source -c collection_source


mongorestore -h host:port -d db_target -c collection_target dump/collection_source.bson

Please refer to the detailed usage of the two tools.

mongodump — MongoDB Manual 3.2