How does mongodb merge multiple database

  mongodb, question

Now there are DBA, DBB, DBC, NewDB in one instance, how to import ABC into NewDB?
The structure is the same, triedFor InsertAndInsertMany, but the data is close to 500W, inserted a few will not work. And the efficiency is too low.
Is there any efficient way?

If it is a copy set, there is a way, not very intuitive, but we dorenameCollection Command:
Note: Be sure to read the link above before starting work.

{ renameCollection: "<source_namespace>", to: "<target_namespace>", dropTarget: <true|false> }
Field Type Description
renameCollection string The namespace of the collection to rename. The namespace is a combination of the database name and the name of the collection.
to string The new namespace of the collection. If the new namespace specifies a different database, the renameCollection command copies the collection to the new database and drops the source collection.
dropTarget boolean Optional. If true, mongod will drop the target of renameCollection prior to renaming the collection. The default value is false.


use admin
 db.runCommand( { renameCollection: "", to: "" } )
 db.runCommand( { renameCollection: "DBA.yyy", to: "NewDB.yyy" } )