Skip to content

matszrmn/NodeJS_Copy_Collection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

NodeJS_Copy_Collection

This code was created to copy a entire MongoDB collection via NodeJS.

  • Before starting, be sure to change the following variables:

  • urlSource

  • urlTarget

  • dbSource

  • dbTarget

  • collectionSource

  • collectionTarget

  • chunks

    • This variable refers to the number of documents to be copied for each connection to the database.
    • You can leave the default value of 100 if desired.
    • You can use a higher or lower number, depending on the performance of your server.
  • timeOut

    • This variable refers to the timeout (in milliseconds) between each connection to the database.
    • You can leave the default value of 7000 if desired.
    • You can use a higher or lower number, depending on the performance of your server.
    • You can even replace the line

     setTimeout(copyDocumentsInChunks, timeOut, skip + limit, limit, count, collectionSource);

     with

     copyDocumentsInChunks(skip + limit, limit, count, collectionSource);

     To completely remove the wait between the connections.

About

Simple code for copying Mongo Collection into pieces.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors