{"id":23045489,"url":"https://github.com/cdxoo/mongodb-restore","last_synced_at":"2025-08-14T23:32:00.982Z","repository":{"id":57100899,"uuid":"252538535","full_name":"cdxOo/mongodb-restore","owner":"cdxOo","description":"Simple module to restore MongoDB dumps from BSON files","archived":false,"fork":false,"pushed_at":"2024-06-28T11:07:44.000Z","size":424,"stargazers_count":7,"open_issues_count":3,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-02T08:10:56.647Z","etag":null,"topics":["bson","bson-files","mongodb","mongodump","mongorestore","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cdxOo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-04-02T18:43:49.000Z","updated_at":"2025-03-23T06:03:55.000Z","dependencies_parsed_at":"2024-06-28T11:57:50.538Z","dependency_job_id":"f5f0e3f3-6470-46eb-a04f-1ce6b6254bc5","html_url":"https://github.com/cdxOo/mongodb-restore","commit_stats":{"total_commits":85,"total_committers":1,"mean_commits":85.0,"dds":0.0,"last_synced_commit":"0cbdfb88176ab8518c8ce251805c85ec16a30b50"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/cdxOo/mongodb-restore","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdxOo%2Fmongodb-restore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdxOo%2Fmongodb-restore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdxOo%2Fmongodb-restore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdxOo%2Fmongodb-restore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cdxOo","download_url":"https://codeload.github.com/cdxOo/mongodb-restore/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cdxOo%2Fmongodb-restore/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270500002,"owners_count":24595150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-14T02:00:10.309Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bson","bson-files","mongodb","mongodump","mongorestore","nodejs"],"created_at":"2024-12-15T21:20:56.864Z","updated_at":"2025-08-14T23:32:00.708Z","avatar_url":"https://github.com/cdxOo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @cdxoo/mongodb-restore\n\nSimple pure js module to restore MongoDB dumps from BSON files. No extra tools required (i.e. mongo-tools).\n\n\n## Installation\n\n    npm install --save @cdxoo/mongodb-restore\n\n\n## Resources\n\n* [Changelog](https://github.com/cdxOo/mongodb-restore/blob/2.x/CHANGELOG.md)\n\n\n\n## Usage\n\n```javascript\nconst restore = require('@cdxoo/mongodb-restore'),\n      uri = 'mongodb://127.0.0.1:27001/';\n\n// restore multi-database dump\nawait restore.dump({\n    uri,\n    from: '../dumps/mydump/'\n});\n\n// restore single database\nawait restore.database({\n    uri,\n    database: 'my-database-name',\n    from: '../dumps/mydump/db-1/'\n});\n\n// restore single collection\nawait restore.collection({\n    uri,\n    database: 'my-database-name',\n    collection: 'foo',\n    from: '../dumps/mydump/db-1/foo.bson'\n});\n\n// restore from a buffer containing bson\nvar myBuffer = fs.readFileSync('./foo.bson')\nawait restore.buffer({\n    uri,\n    database: 'my-database-name',\n    collection: 'foo',\n    from: myBuffer\n});\n```\n\n## Parameters\n```javascript\nawait restore.dump({\n    con: await MongoClient.connect(uri),\n                  // An existing mongodb connection to use.\n                  // Either this or \"uri\" must be provided\n    uri: 'mongodb://127.0.0.1:27001/',\n                  // URI to the Server to use.\n                  // Either this or \"con\" must be provided.\n    from: '../dumps/my-dump',\n                  // path to the server dump, contains sub-directories\n                  // that themselves contain individual database\n                  // dumps\n    clean: true,   // wether the collections should be cleaned before\n                  // inserting the documents from the dump files\n                  // optional; default = true\n    onCollectionExists: 'throw',\n                  // how to handle collections that already exist\n                  // on the server; when set to \"throw\" (default)\n                  // the restore will throw an error;\n                  // when set to \"overwrite\" the restore will proceed\n                  // and insert the dump data to the collection\n                  // (and remove existing items when clean == true)\n                  // optional, default: 'throw'\n                  // available options:\n                  //    'throw'\n                  //    'overwrite'\n    transformDocuments: (doc, { collection, database }) =\u003e {\n        var transformed = doStuff(doc);\n        return transformed;\n    },            // transform the documents while restoring them\n});\n\nawait retore.database({\n    // same as in dump()\n    con, uri, clean, onCollectionExists, transformDocuments\n    //\n    \n    database: 'my-database-name',\n                  // name of the database that will be created\n                  // on the mongodb server from the dump\n    from: '../dumps/mydump/db-1/',\n                  // path to the database dump directory\n                  // should contain one or more bson files\n                  // to restore\n});\n\nawait restore.collection({\n    // same as in database()\n    con,\n    uri,\n    clean,\n    onCollectionExists,\n    transformDocuments,\n    database,\n    //\n    \n    collection: 'my-collection-name',\n                  // name of the collection that the documents\n                  // will be restored into\n    from: '../dumps/mydump/db-1/foo.bson',\n                  // bson file containing the documents\n                  // to be restored\n    limit: 100,   // optionally you can choose to not\n                  // restore all the documents but just\n                  // the first e.g. 100\n                  // optional; default = no limit\n});\n\nawait restore.buffer({\n    // same as in collection()\n    con,\n    uri,\n    clean,\n    onCollectionExists,\n    transformDocuments,\n    database,\n    collection,\n    limit\n    //\n    \n    from: myBuffer,\n                  // a buffer with bson documents that was\n                  // created somehere in advance\n                  // e.g. by fs.readFileSync()\n});\n```\n\n\n## LICENSE\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdxoo%2Fmongodb-restore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcdxoo%2Fmongodb-restore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcdxoo%2Fmongodb-restore/lists"}