{"_id":"@arthurshen/mongodb-einfach","_rev":"5-acf4a113296206fac0e1856284bbbf29","name":"@arthurshen/mongodb-einfach","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"@arthurshen/mongodb-einfach","version":"1.0.0","keywords":[],"author":{"name":"Arthur Shen"},"license":"MIT","_id":"@arthurshen/mongodb-einfach@1.0.0","maintainers":[{"name":"arthurshen","email":"arthurshen@t-online.de"}],"dist":{"shasum":"90a7f160b84cb090be56d06184df03f117daf995","tarball":"https://registry.npmjs.org/@arthurshen/mongodb-einfach/-/mongodb-einfach-1.0.0.tgz","fileCount":7,"integrity":"sha512-Yy7md6N/EjCPC1DXwJW/tuf0AEfnej0H+qVp7wAXiVSwTZ+DBxFcthkZ0ORh9D3qKON7JG9t9MSDpF1kOhYhZA==","signatures":[{"sig":"MEYCIQDtj7FTPnWS/grfnlvXvVyKGuzbZ5iOR9uM/tFAS+FKDwIhANuT4J4eKd6jxDctnYh7MO+dUn0jZ3jNK2rKWHNnXmsY","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33970},"main":"index.js","type":"module","engines":{"node":">=10.0.0"},"gitHead":"d0261943359640518392aec4244ee7bf927b0726","scripts":{"test":"mocha --exit --import=tsx","build":"tsc"},"_npmUser":{"name":"arthurshen","email":"arthurshen@t-online.de"},"_npmVersion":"10.2.3","description":"Simple NodeJS wrapper for MongoDB.","directories":{},"_nodeVersion":"18.19.0","dependencies":{"mongodb":"^6.8.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.16.5","chai":"^4.5.0","mocha":"^10.7.0","dotenv":"^16.4.5","ts-node":"^10.9.2","ts-mocha":"^10.0.0","typescript":"^5.5.4","@types/chai":"^4.3.16","@types/node":"^20.14.13","@types/mocha":"^10.0.7","@types/expect":"^24.3.0","chai-as-promised":"^8.0.0","@types/chai-as-promised":"^7.1.8"},"_npmOperationalInternal":{"tmp":"tmp/mongodb-einfach_1.0.0_1722553239692_0.8666474655473362","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@arthurshen/mongodb-einfach","version":"1.0.1","keywords":[],"author":{"name":"Arthur Shen"},"license":"MIT","_id":"@arthurshen/mongodb-einfach@1.0.1","maintainers":[{"name":"arthurshen","email":"arthurshen@t-online.de"}],"homepage":"https://github.com/arthurshen74/mongodb-einfach#readme","bugs":{"url":"https://github.com/arthurshen74/mongodb-einfach/issues"},"dist":{"shasum":"acf15beb6b183c5591a3fea21d3ce218876335c0","tarball":"https://registry.npmjs.org/@arthurshen/mongodb-einfach/-/mongodb-einfach-1.0.1.tgz","fileCount":7,"integrity":"sha512-DaRfr2wItNA5/F023dJzqm8JXp6Z0Hvh60hgD1osaf8PmKqgXQu5u+a8J7hTTF9v6valsqqH5IeZtB9UvYSG6g==","signatures":[{"sig":"MEUCIQCSSXbLnZzDn7knfBUexuTC1VKButp9Ypp8s5cTU6fV3QIgMGinW5GB1P/Ske3/c06p3ZM8q2uKT5URYv20G0P8iSQ=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":33993},"main":"index.js","type":"module","engines":{"node":">=10.0.0"},"gitHead":"0d601cf2bc7ccad9d0c92d57b128eb33e40927fd","scripts":{"test":"mocha --exit --import=tsx","build":"tsc"},"_npmUser":{"name":"arthurshen","email":"arthurshen@t-online.de"},"repository":{"url":"git+https://github.com/arthurshen74/mongodb-einfach.git","type":"git"},"_npmVersion":"10.2.3","description":"Simple TypeScript NodeJS/NextJS wrapper for MongoDB.","directories":{},"_nodeVersion":"18.19.0","dependencies":{"mongodb":"^6.8.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.16.5","chai":"^4.5.0","mocha":"^10.7.0","dotenv":"^16.4.5","ts-node":"^10.9.2","typescript":"^5.5.4","@types/chai":"^4.3.16","@types/node":"^20.14.13","@types/mocha":"^10.0.7","@types/expect":"^24.3.0"},"_npmOperationalInternal":{"tmp":"tmp/mongodb-einfach_1.0.1_1722553931644_0.787021277160282","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@arthurshen/mongodb-einfach","version":"1.0.2","keywords":[],"author":{"name":"Arthur Shen"},"license":"MIT","_id":"@arthurshen/mongodb-einfach@1.0.2","maintainers":[{"name":"arthurshen","email":"arthurshen@t-online.de"}],"homepage":"https://github.com/arthurshen74/mongodb-einfach#readme","bugs":{"url":"https://github.com/arthurshen74/mongodb-einfach/issues"},"dist":{"shasum":"24710a03d515257f764870bb1aa5eefbdc182c09","tarball":"https://registry.npmjs.org/@arthurshen/mongodb-einfach/-/mongodb-einfach-1.0.2.tgz","fileCount":8,"integrity":"sha512-bjBv8C20ayhVCkW3ZQKGRJdBuWfoS6PAAU1PggwDT+zpsjW/IIpBzEe7BQlyEE+R2IJbit/L8IdXjJfbRbyryw==","signatures":[{"sig":"MEUCIQCPIvf5O1SH3Gnjh/UnFQA/aivgrjb5fvqDhvRgydZgPQIgW/XjgjSGJiyGrdIIgXYeFnlieZ6tNmOvHq7915KKC2Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35196},"main":"index.js","type":"module","engines":{"node":">=10.0.0"},"gitHead":"55ff415ae25423933f4a8514e33c07754b074e08","scripts":{"test":"mocha --exit --import=tsx","build":"tsc"},"_npmUser":{"name":"arthurshen","email":"arthurshen@t-online.de"},"repository":{"url":"git+https://github.com/arthurshen74/mongodb-einfach.git","type":"git"},"_npmVersion":"10.2.3","description":"Simple TypeScript NodeJS/NextJS wrapper for MongoDB.","directories":{},"_nodeVersion":"18.19.0","dependencies":{"mongodb":"^6.8.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.16.5","chai":"^4.5.0","mocha":"^10.7.0","dotenv":"^16.4.5","ts-node":"^10.9.2","typescript":"^5.5.4","@types/chai":"^4.3.16","@types/node":"^20.14.13","@types/mocha":"^10.0.7","@types/expect":"^24.3.0"},"_npmOperationalInternal":{"tmp":"tmp/mongodb-einfach_1.0.2_1722608738653_0.044515869603339864","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@arthurshen/mongodb-einfach","version":"1.0.3","keywords":[],"author":{"name":"Arthur Shen"},"license":"MIT","_id":"@arthurshen/mongodb-einfach@1.0.3","maintainers":[{"name":"arthurshen","email":"arthurshen@t-online.de"}],"homepage":"https://github.com/arthurshen74/mongodb-einfach#readme","bugs":{"url":"https://github.com/arthurshen74/mongodb-einfach/issues"},"dist":{"shasum":"569927881a63ce747bcdf17af8347b269ea606de","tarball":"https://registry.npmjs.org/@arthurshen/mongodb-einfach/-/mongodb-einfach-1.0.3.tgz","fileCount":8,"integrity":"sha512-bv/tMVqhYnlbmcopCfK9Fzj4lF1qlq1FRbz9N0t/qI457sgkrrmwgZkAwEu94R6mDrn+eTkTfqkYyMm7ZAfUpQ==","signatures":[{"sig":"MEQCIFyrtRIDC5FXKhK1bHzxq+LMMtplRHE563SIn2ReJGZXAiBmrxj1UBBV9Ucd8PWymSmSi+x8p9fAr1ncycVUaN5vyw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":35221},"main":"index.js","type":"module","types":"index.d.ts","engines":{"node":">=10.0.0"},"gitHead":"0d79fe4d575d5831407d28a35971cf82f189d520","scripts":{"test":"mocha --exit --import=tsx","build":"tsc"},"_npmUser":{"name":"arthurshen","email":"arthurshen@t-online.de"},"repository":{"url":"git+https://github.com/arthurshen74/mongodb-einfach.git","type":"git"},"_npmVersion":"10.2.3","description":"Simple TypeScript NodeJS/NextJS wrapper for MongoDB.","directories":{},"_nodeVersion":"18.19.0","dependencies":{"mongodb":"^6.8.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.16.5","chai":"^4.5.0","mocha":"^10.7.0","dotenv":"^16.4.5","ts-node":"^10.9.2","typescript":"^5.5.4","@types/chai":"^4.3.16","@types/node":"^20.14.13","@types/mocha":"^10.0.7","@types/expect":"^24.3.0"},"_npmOperationalInternal":{"tmp":"tmp/mongodb-einfach_1.0.3_1722609903942_0.06267677656887294","host":"s3://npm-registry-packages"}},"1.0.4":{"name":"@arthurshen/mongodb-einfach","version":"1.0.4","keywords":[],"author":{"name":"Arthur Shen"},"license":"MIT","_id":"@arthurshen/mongodb-einfach@1.0.4","maintainers":[{"name":"arthurshen","email":"arthurshen@t-online.de"}],"homepage":"https://github.com/arthurshen74/mongodb-einfach#readme","bugs":{"url":"https://github.com/arthurshen74/mongodb-einfach/issues"},"dist":{"shasum":"47914613701e836b905cd173735a0bf52a43cc92","tarball":"https://registry.npmjs.org/@arthurshen/mongodb-einfach/-/mongodb-einfach-1.0.4.tgz","fileCount":10,"integrity":"sha512-LC6UYfCzPNzEwiXxdcTTJbbXF9Duyo9/EE6AEUJEmBXmwuf1kdVZdoBnNpFJpQR54oQuu/gH9GzHNsxERsCXZQ==","signatures":[{"sig":"MEYCIQDpofJBRx7j9r00dGZl2J4qb2K8+dReGyUfxDj+6ErRegIhAN3uH4VJWyQ9fEm0Y8PgwaSxKk2ZalbQMxZZLhGr41gn","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":56341},"main":"index.js","type":"module","types":"index.d.ts","engines":{"node":">=10.0.0"},"gitHead":"6d2ec420e4242641b16ed1299ee8bd1f1b65d980","scripts":{"test":"mocha --exit --import=tsx","build":"tsc"},"_npmUser":{"name":"arthurshen","email":"arthurshen@t-online.de"},"repository":{"url":"git+https://github.com/arthurshen74/mongodb-einfach.git","type":"git"},"_npmVersion":"10.2.3","description":"Simple TypeScript NodeJS/NextJS wrapper for MongoDB.","directories":{},"_nodeVersion":"18.19.0","dependencies":{"mongodb":"^6.8.0"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.16.5","chai":"^4.5.0","mocha":"^10.7.0","dotenv":"^16.4.5","ts-node":"^10.9.2","typescript":"^5.5.4","@types/chai":"^4.3.16","@types/node":"^20.14.13","@types/mocha":"^10.0.7","@types/expect":"^24.3.0"},"_npmOperationalInternal":{"tmp":"tmp/mongodb-einfach_1.0.4_1722610088028_0.20601893794122828","host":"s3://npm-registry-packages"}},"1.0.5":{"name":"@arthurshen/mongodb-einfach","version":"1.0.5","description":"Simple TypeScript NodeJS/NextJS wrapper for MongoDB.","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","scripts":{"build":"tsup","test":"mocha --exit --import=tsx"},"keywords":[],"author":{"name":"Arthur Shen"},"license":"MIT","dependencies":{"mongodb":"^6.8.0"},"devDependencies":{"@types/chai":"^4.3.16","@types/expect":"^24.3.0","@types/mocha":"^10.0.7","@types/node":"^20.14.13","chai":"^4.5.0","dotenv":"^16.4.5","mocha":"^10.7.0","ts-node":"^10.9.2","tsup":"^8.2.4","tsx":"^4.16.5","typescript":"^5.5.4"},"engines":{"node":">=10.0.0"},"type":"module","repository":{"type":"git","url":"git+https://github.com/arthurshen74/mongodb-einfach.git"},"_id":"@arthurshen/mongodb-einfach@1.0.5","gitHead":"cb9182693db7853f0cb3f3de9f5f9b9ecbc90f92","bugs":{"url":"https://github.com/arthurshen74/mongodb-einfach/issues"},"homepage":"https://github.com/arthurshen74/mongodb-einfach#readme","_nodeVersion":"18.19.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-0YUCVhXV0OPf2TjOYXbB0jS+uSUbgxAvIb/aQoQzllLtYL9uWjU7Om5m2KQNtuBTtU0HZh5umb93+wm3kqrxqQ==","shasum":"4c7a6cc0ca577be0d651aaccf4fd9f9b9806b69e","tarball":"https://registry.npmjs.org/@arthurshen/mongodb-einfach/-/mongodb-einfach-1.0.5.tgz","fileCount":8,"unpackedSize":43904,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBSW/zEIdKrO3l2YGJZHEnHPyinCp56oY1r/+Qzf1gsiAiA/oXWD2towC13f+H7hHVpHkgecZGfbjzau9AxnLv+kTg=="}]},"_npmUser":{"name":"arthurshen","email":"arthurshen@t-online.de"},"directories":{},"maintainers":[{"name":"arthurshen","email":"arthurshen@t-online.de"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mongodb-einfach_1.0.5_1722612071804_0.17499547216664224"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-01T23:00:39.551Z","modified":"2024-08-02T15:21:12.151Z","1.0.0":"2024-08-01T23:00:39.836Z","1.0.1":"2024-08-01T23:12:11.864Z","1.0.2":"2024-08-02T14:25:38.831Z","1.0.3":"2024-08-02T14:45:04.117Z","1.0.4":"2024-08-02T14:48:08.212Z","1.0.5":"2024-08-02T15:21:11.972Z"},"bugs":{"url":"https://github.com/arthurshen74/mongodb-einfach/issues"},"author":{"name":"Arthur Shen"},"license":"MIT","homepage":"https://github.com/arthurshen74/mongodb-einfach#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/arthurshen74/mongodb-einfach.git"},"description":"Simple TypeScript NodeJS/NextJS wrapper for MongoDB.","maintainers":[{"name":"arthurshen","email":"arthurshen@t-online.de"}],"readme":"# EinfachMongoDbCollection Class\n\nMongoDB Einfach\n\nA simple TypeScript MongoDB wrapper for NodeJS/NextJS.\n\n**Version:** 1.0.0\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Installation](#installation)\n- [Usage](#usage)\n- [API](#api)\n  - [Constructor](#constructor)\n  - [Static Methods](#static-methods)\n    - [clients()](#clients)\n  - [Instance Methods](#instance-methods)\n    - [count()](#count)\n    - [get()](#get)\n    - [getById(id)](#getbyid)\n    - [insert(data)](#insert)\n    - [update(data)](#update)\n    - [remove(id)](#remove)\n    - [drop()](#drop)\n\n## Introduction\n\n`EinfachMongoDbCollection` is a simple MongoDB wrapper for NodeJS/NextJS\nthat I use for my basic CRUD operations. It is opinionated and only handles\na couple of operations that I use all the time. I expose a static Map of\nMongoClients with the key being the URL for the server. This way you can\nrun more custom operations such as aggregations.\n\n## Installation\n\nTo use `EinfachMongoDbCollection`, ensure you have MongoDB Node.js driver\ninstalled:\n\n```bash\nnpm install mongodb\n# or\nyarn add mongodb\n```\n\n## Usage\n\n```typescript\nimport {\n  EinfachMongoDbCollection,\n  EinfachMongoDbDocument,\n} from './path/to/EinfachMongoDbCollection';\n\n// create your data structure which extends EinfachMongoDbDocument\ntype MyDocument = EinfachMongoDbDocument & {\n  name: string;\n  age: number;\n};\n\n// Initialize a new instance of EinfachMongoDbCollection\nconst collection = new EinfachMongoDbCollection<MyDocument>(\n  'mongodb://localhost:27017',\n  'myDatabase',\n  'myCollection'\n);\n\n// Example usage:\nasync function exampleUsage() {\n  // Insert a document\n  const insertedDoc = await collection.insert({\n    name: 'John Doe',\n    age: 30,\n  });\n\n  // Update a document\n  const updatedDoc = await collection.update({\n    _id: insertedDoc._id,\n    name: 'Jane Doe',\n    age: 35,\n  });\n\n  // Get a document by ID\n  const foundDoc = await collection.getById(insertedDoc._id.toString());\n\n  // Remove a document\n  const removed = await collection.remove(insertedDoc._id.toString());\n}\n\nexampleUsage();\n```\n\n## API\n\n### Constructor\n\nCreates an instance of `EinfachMongoDbCollection`.\n\n```typescript\nconstructor(\n  serverUrl: string,\n  dbName: string,\n  collectionName: string,\n  clientOptions?: MongoClientOptions\n)\n```\n\n- **serverUrl**: MongoDB server URL.\n- **dbName**: Name of the database.\n- **collectionName**: Name of the collection.\n- **clientOptions**: Optional MongoDB client options.\n\n### Static Methods\n\n#### clients()\n\nReturns a Map of MongoDB clients for connection pooling. A MongoClient is\nadded to the map **ONLY AFTER** an instance method has been called. **_It\nis not enough to just instantiate the instance, you MUST call a method in\norder for the MongoClient to be available_**\n\n```typescript\nstatic clients(): Map<string, MongoClient>\n```\n\n### Instance Methods\n\n#### count()\n\nCounts the number of documents in the collection.\n\n```typescript\nasync count(): Promise<number>\n```\n\n#### get()\n\nRetrieves all documents from the collection.\n\n```typescript\nasync get(): Promise<T[]>\n```\n\n#### getById(id)\n\nRetrieves a document by its ID.\n\n```typescript\nasync getById(id: string): Promise<T | null>\n```\n\n- **id**: String ID of the document.\n\n#### insert(data)\n\nInserts a new document into the collection.\n\n```typescript\nasync insert(data: T): Promise<T>\n```\n\n- **data**: Document data to insert.\n\n#### update(data)\n\nUpdates a document in the collection.\n\n```typescript\nasync update(data: T): Promise<T>\n```\n\n- **data**: Updated document data.\n\n#### remove(id)\n\nRemoves a document from the collection by its ID.\n\n```typescript\nasync remove(id: string): Promise<boolean>\n```\n\n- **id**: String ID of the document to remove.\n\n#### drop()\n\nDrops (deletes) the collection.\n\n```typescript\nasync drop(): Promise<boolean>\n```\n\n---\n","readmeFilename":"README.md"}