From 1df3f51e536b25a1672497fbc5590d9ab4d1beaa Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 14 Apr 2024 17:15:00 +0200 Subject: [PATCH] update tsconfig --- npmextra.json | 18 ++++++-- package.json | 16 ++++++- readme.hints.md | 1 + readme.md | 112 +++++++++++++++++++++++++++++++++++------------- 4 files changed, 112 insertions(+), 35 deletions(-) create mode 100644 readme.hints.md diff --git a/npmextra.json b/npmextra.json index 2204baf..c721c89 100644 --- a/npmextra.json +++ b/npmextra.json @@ -5,17 +5,29 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "mongodump", - "description": "a tool to handle dumps of mongodb databases", + "description": "A tool to create and manage dumps of MongoDB databases, supporting data export and import.", "npmPackagename": "@push.rocks/mongodump", "license": "MIT", - "projectDomain": "push.rocks" + "projectDomain": "push.rocks", + "keywords": [ + "mongodb", + "database backup", + "data dump", + "database restore", + "mongodb export", + "mongodb import", + "database management", + "mongodb management", + "data backup", + "data recovery" + ] } }, "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" }, - "tsdocs": { + "tsdoc": { "legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n" } } \ No newline at end of file diff --git a/package.json b/package.json index 7fb906b..9300b9b 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/mongodump", "version": "1.0.8", "private": false, - "description": "a tool to handle dumps of mongodb databases", + "description": "A tool to create and manage dumps of MongoDB databases, supporting data export and import.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "type": "module", @@ -44,5 +44,17 @@ "@pushrocks/smartpromise": "^3.1.7", "@tsclass/tsclass": "^4.0.3", "mongodb": "^4.6.0" - } + }, + "keywords": [ + "mongodb", + "database backup", + "data dump", + "database restore", + "mongodb export", + "mongodb import", + "database management", + "mongodb management", + "data backup", + "data recovery" + ] } \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index bcd1f76..61c95c1 100644 --- a/readme.md +++ b/readme.md @@ -1,39 +1,91 @@ -# @pushrocks/mongodump -a tool to handle dumps of mongodb databases +# @push.rocks/mongodump +a tool to handle dumps of MongoDB databases -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/mongodump) -* [gitlab.com (source)](https://gitlab.com/pushrocks/mongodump) -* [github.com (source mirror)](https://github.com/pushrocks/mongodump) -* [docs (typedoc)](https://pushrocks.gitlab.io/mongodump/) - -## Status for master - -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/mongodump/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/mongodump/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/mongodump)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/mongodump)](https://lossless.cloud) -TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) -node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) -PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/mongodump)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/mongodump)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/mongodump)](https://lossless.cloud) -Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud) +## Install +To use @push.rocks/mongodump in your project, run: +```bash +npm install @push.rocks/mongodump --save +``` ## Usage -Use TypeScript for best in class intellisense +This guide provides an overview of how to work with @push.rocks/mongodump to handle dumps of MongoDB databases efficiently. -## Contribution +### Setting up a MongoDB Dump Target +First, you'll need to describe your MongoDB database using an interface provided by the module. Here's a sample descriptor: -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +```typescript +import { IMongoDescriptor } from '@tsclass/tsclass'; +import { MongoDump, MongoDumpTarget } from '@push.rocks/mongodump'; -For further information read the linked docs at the top of this readme. +const myMongoDescriptor: IMongoDescriptor = { + mongoDbName: '', + mongoDbUser: '', + mongoDbPass: '', + mongoDbUrl: 'mongodb+srv://:@/?retryWrites=true&w=majority', +}; +``` -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +### Creating and Using the MongoDump Instance +To interact with MongoDB for dumping purposes, you'll use the `MongoDump` class: -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) +```typescript +async function setupMongoDump() { + const mongoDump = new MongoDump(); + const mongoDumpTarget = await mongoDump.addMongoTargetByMongoDescriptor(myMongoDescriptor); + + // mongoDumpTarget can now be used for further operations +} +setupMongoDump(); +``` + +### Dumping Collections to a Directory +To dump the collections of a database into a directory with files representing each document, you can use the `dumpCollectionToDir` method. This method is useful for creating backups or migrating data: + +```typescript +async function dumpCollections() { + const mongoDump = new MongoDump(); + const mongoDumpTarget = await mongoDump.addMongoTargetByMongoDescriptor(myMongoDescriptor); + + await mongoDumpTarget.dumpAllCollectionsToDir('./path/to/dumpDir', null, true); + // This dumps all collections to the specified directory, cleaning the directory before dumping. +} +dumpCollections(); +``` + +### Advanced Dumping Options +For more control over the dumping process, including naming conventions for dumped files or handling specific collections, you can explore methods like `dumpCollectionToDir` for individual collections and advanced configurations concerning directory cleanliness and document naming. + +### Shutting Down Properly +It's important to close down database connections properly once your dumping operations are complete: + +```typescript +async function shutDownMongoDump() { + const mongoDump = new MongoDump(); + await mongoDump.stop(); + // Closes all open database connections gracefully +} +shutDownMongoDump(); +``` + +### Conclusion +The @push.rocks/mongodump module provides a flexible approach to handling MongoDB database dumps, whether it's for backup, migration, or other purposes. By leveraging TypeScript and modern async patterns, it integrates smoothly into modern Node.js applications focused on MongoDB interactions. + +## License and Legal Information + +This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. + +**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file. + +### Trademarks + +This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH. + +### Company Information + +Task Venture Capital GmbH +Registered at District court Bremen HRB 35230 HB, Germany + +For any legal inquiries or if you require further information, please contact us via email at hello@task.vc. + +By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.