{"id":15154486,"url":"https://github.com/aneldev/dyna-mongo-db","last_synced_at":"2026-02-10T13:35:30.404Z","repository":{"id":38349524,"uuid":"301970115","full_name":"aneldev/dyna-mongo-db","owner":"aneldev","description":null,"archived":false,"fork":false,"pushed_at":"2022-06-23T08:08:20.000Z","size":607,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-23T15:57:07.369Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/aneldev.png","metadata":{"files":{"readme":"README.Upgrade.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-10-07T08:17:56.000Z","updated_at":"2021-12-22T07:42:53.000Z","dependencies_parsed_at":"2022-08-25T01:51:44.836Z","dependency_job_id":null,"html_url":"https://github.com/aneldev/dyna-mongo-db","commit_stats":null,"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"purl":"pkg:github/aneldev/dyna-mongo-db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneldev%2Fdyna-mongo-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneldev%2Fdyna-mongo-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneldev%2Fdyna-mongo-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneldev%2Fdyna-mongo-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aneldev","download_url":"https://codeload.github.com/aneldev/dyna-mongo-db/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aneldev%2Fdyna-mongo-db/sbom","scorecard":{"id":195591,"data":{"date":"2025-08-11","repo":{"name":"github.com/aneldev/dyna-mongo-db","commit":"6d973c6382d1d28692557794a8a8b74a44478838"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"78 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-w8qv-6jwh-64r5","Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq","Warn: Project is vulnerable to: GHSA-3wcq-x3mq-6r9p","Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc","Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx","Warn: Project is vulnerable to: GHSA-74fj-2j2h-c42q","Warn: Project is vulnerable to: GHSA-pw2r-vq6v-hr8c","Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc","Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j","Warn: Project is vulnerable to: GHSA-c7qv-q95q-8v27","Warn: Project is vulnerable to: GHSA-4www-5p9h-95mh","Warn: Project is vulnerable to: GHSA-9gqv-wp59-fq42","Warn: Project is vulnerable to: GHSA-qqgx-2p2h-9c37","Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22","Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp","Warn: Project is vulnerable to: GHSA-7r28-3m3f-r2pr","Warn: Project is vulnerable to: GHSA-r8j5-h5cx-65gg","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-vxvm-qww3-2fh7","Warn: Project is vulnerable to: GHSA-5rrq-pxf6-6jx5","Warn: Project is vulnerable to: GHSA-8fr3-hfg3-gpgp","Warn: Project is vulnerable to: GHSA-gf8q-jrpm-jvxq","Warn: Project is vulnerable to: GHSA-2r2c-g63r-vccr","Warn: Project is vulnerable to: GHSA-cfm4-qjh2-4765","Warn: Project is vulnerable to: GHSA-x4jg-mjrx-434g","Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p","Warn: Project is vulnerable to: GHSA-rp65-9cf3-cjxr","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-rhx6-c78j-4q9w","Warn: Project is vulnerable to: GHSA-566m-qj78-rww5","Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-44c6-4v22-4mhx","Warn: Project is vulnerable to: GHSA-4x5v-gmq8-25ch","Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p","Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc","Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v","Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j","Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986","Warn: Project is vulnerable to: GHSA-wr3j-pwj9-hqq6","Warn: Project is vulnerable to: GHSA-4v9v-hfq4-rm2v","Warn: Project is vulnerable to: GHSA-9jgg-88mc-972h","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-16T21:46:18.866Z","repository_id":38349524,"created_at":"2025-08-16T21:46:18.867Z","updated_at":"2025-08-16T21:46:18.867Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29300984,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T12:55:56.056Z","status":"ssl_error","status_checked_at":"2026-02-10T12:55:55.692Z","response_time":65,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-09-26T17:40:40.356Z","updated_at":"2026-02-10T13:35:30.378Z","avatar_url":"https://github.com/aneldev.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dyna Mongo DB - Upgrade Mechanism\n\n# Full version of the DynaMongoDb config\n\n```\ninterface IDynaMongoDBConfig {\n  connectionString: string;\n  databaseName: string;\n  upgradeDatabase?: IDatabaseUpgrade[];\n  upgradeCollections?: ICollectionsUpgrades;\n  onUpgradeError?: (collectionName: string, version: number, error: any) =\u003e void;\n}\n```\n\n- `upgradeDatabase`: To upgrade a whole database.\n- `upgradeCollections`: To upgrade a collection _or dynamic collections_\n- `upgradeDatabase`: To catch the Upgrade errors from both of the above methods.\n\n\u003e You can use both Database and Collection Upgrades.\n\n# Upgrade database\n\n## Setup\n\nTo make a database upgradable you have to pass the `upgradeDatabase` on `DynaMongoDB` instantiation.\n\n```\nconst dmdb = new DynaMongoDB({\n  connectionString: '\u003cmy mongodb connection string\u003e', \n  databaseName: 'happy-cars-production',\n  upgradeDatabase, // \u003c-- this one\n  onUpgradeError: (collectionName: string, version: number, error: any) =\u003e console.error('Upgrade failed on collection', collection, 'version', version, error),\n})\n```\n\nThis property should be an array of `IDatabaseUpgrade` which it is:\n\n```\ninterface IDatabaseUpgrade {\n  version: number;\n  title: string;\n  description?: string;\n  method: (params: { db: Db }) =\u003e Promise\u003cvoid\u003e;\n}\n```\n- `version`: every version should be unique, the version would be non-sequential\n- `title`: Title of this Upgrade, this is consoled\n- `description`: (optional) Few words about this Upgrade, _not consoled_.\n- `method`: The callback method, a promised one, will perform the Upgrade for this version. \n\nThe `method` should be resolved when all work has been completed.\n\nThe `method` would be rejected if something went completely wrong. If an exception is thrown again, it is assumed as rejected. In this case the method that started the operation (`getCollection()`, `find()`) will be rejected. A `console.error` by default is consoled you will see this error on the server's console.\n\nExample for the `upgradeDatabase` property:\n\n```\nconst upgradeDatabase: IDatabaseUpgrade[] = [\n  {\n    version: 1,\n    title: 'Create users table',\n    method: async ({db}) =\u003e {\n      await db.createCollection('users');\n    },\n  },\n  {\n    version: 12,\n    title: 'Create Users name indexer',\n    method: async ({db}) =\u003e {\n      const collection = await db.collection('users')\n      await collection.createIndex(\n        { date: 1 },\n        { name: 'name indexer' },\n      );\n    },\n  },\n];\n```\n\u003e NOTE: In the method always `await` the operations!\n\n\u003e NOTE: Do not use the instance of DynaMongoDB (like dmdb) inside the Upgrade Methods!\n\n## Lifecycle\n\nThe Upgrade methods are running on Database's connect.\n\n# Upgrade Collection\n\n## Setup\n\nLike the databases, you can Upgrade collections in exactly the same way. You just have to create a dictionary object using the Collection name as key.\n\nFor Example:\n\n```\nconst dmdb = new DynaMongoDB({\n  connectionString: '\u003cmy mongodb connection string\u003e', \n  databaseName: 'happy-cars-production',\n  upgradeCollections, // \u003c-- this one\n  onUpgradeError: (collectionName: string, version: number, error: any) =\u003e console.error('Upgrade failed on collection', collection, 'version', version, error),\n})\n```\n\nWhere `collectionUpgrades` is:\n\n```\nconst collectionUpgrades: ICollectionsUpgrades = {\n  \"users\": { // \u003c-- this is the name of the Collection\n    upgrades: [\n      {\n        version: 1,\n        title: 'Creation of the collection',\n        method: async ({collectionName, db}) =\u003e {\n          // Note: Use the `collectionName` of the argument and not hardcoded the `users`!\n          await db.createCollection(collectionName);\n        },\n      },\n      {\n        version: 2,\n        title: 'Add the first doc',\n        method: async ({db, collectionName}) =\u003e {\n          const collection = await db.collection('users')\n          await collection.createIndex(\n            { loginName: 1 },\n            { name: 'Login name indexer' },\n          );\n        },\n      },\n    ],\n  },\n};\n```\n\n\u003e NOTE: In the method always `await` the operations!\n\n\u003e NOTE: In the `method` use **always** the `collectionName` that is provided by the argument, to support the Dynamic Collections! _For dynamic collections, the collection name will be different._\n\u003e\n\u003e NOTE: Do not use the instance of DynaMongoDB (like dmdb) inside the Upgrade Methods!\n\n## Usage \n\nThen you can use the `users` collection without even creating it.\n\n```\nconst usersCollection = await dmdb.getCollection('users');\nusersCollection.insertOne({id: 1, fname: 'John', lname: 'Smith', loginName: 'jsmith'});\n```\n\nOnce we have Upgrade methods for the `users` Collection, we can create dynamic Collections that will use these Upgrades and have the same features!\n\n```\nconst usersCollection = await dmdb.getCollection('super-company---users');\n// At this point the all upgrades of the `\"users\"` Collection have been applied.\nusersCollection.insertOne({id: 1, fname: 'John', lname: 'Smith', loginName: 'jsmith'});\n```\n\n## Lifecycle\n\nThe Upgrade operation for a collection is taking part on the first use of the Collection after DB's connection.\n\nIf you re-connect to DB, the Upgrade operation will take part on first use of the Collection again.\n\nIf an Upgrade version fails, it will be retried on the next Collection's usage.\n\nIf you add on runtime Upgrade methods (for development or testing) you should re-connect to DB. \n\n# Upgrade Dynamic Connections (the three dashes `---`)\n\nDynamic Collection is a Collection with a name that ends with `---\u003cname\u003e`.\n\nImagine that there is an Upgrade for the Collection with the name `users`.\nIf you create a Collection with the name `super-company---users`, then this Collection is called dynamic since the Upgrade methods of the `users` Collection will be applied on it.\n\nAlso, it is not needed to have a collection with an exact name. For instance, it is not required to have a Collection with the name `users`. You can have Collections that are ending with `---users`, and the Upgrades will be applied on them.\n\nOn the other hand, if there are no Upgrades for the `users` Collection, nothing will happen, no errors. At a later time, if you create Upgrades the `users`, they will be applied to `users` and all Collections ending with `-- users`.\n\n# Error handling\n\nThe Upgrade methods (like the old SQL migration scripts) should not fail.  \n\nThe Upgrade Fails will bubble up to any DB method of Dyna Mongo DB.\nThis is normal. The same happens for any kind of error, network error, disk error, anything. \nThe error would be something temporary or... permanent. _Deal with it._\n\nTo catch the Upgrade Fails use the `onUpgradeError` callback.\n\n# Upgrade methods\n\nYou don’t need to use these upgrade methods except if you want to upgrade the database or collections on Application’s upgrade time.\n\n## upgradeDatabase(): Promise\u003cIUpgradeCollectionResults\u003e\n\nIt runs the needed Upgrade Methods to Upgrade the database\n\n## upgradeCollection(collectionName: string): Promise\u003cIUpgradeCollectionResults\u003e\n\nIt runs the needed Upgrade Methods to Upgrade the collection and the dynamic collections of this `collectionName`\n\n## Upgrade methods error handling\n\nIf an error occurs, the Promised methods will be fulfilled with rejection of the error.\n\n## Return interface or the upgrade methods\n\nOn success Upgrade, the following object is resolved.\n```\ninterface IUpgradeCollectionResults {\n  initialVersion: number | null;\n  upgradeToVersion: number | null;\n  hasUpgrades: boolean | null;\n  plannedUpgrades: number;\n  appliedUpgrades: number;\n}\n```\n\n# Test/Debug upgrade methods\n\nYou can use the upgrade methods to see if the methods are compatible with a production db (with a copy of production db of course).\n\nIf you want to change the Upgrade version of the database, you can change it on `dyna-mongo-db--upgrade-manager` collection.\n\nFor the Database Upgrade version, the collection name is `@@dyna-mongo-db--database`.\n\nThere is a debug method to change the version number programmatically: \n\n`_debug_changeVersion(collectionName: string, version: number): Promise\u003cvoid\u003e`\n\n# Technical info\n\nThe Dyna Mongo DB keeps the versions on `dyna-mongo-db--upgrade-manager` collection. _Do not drop this Collection._\n\n# Sum up\n\n- Upgrades are just Promised methods.\n- Inside these methods, we have only the instance of the MongoDB `db`.\n- Through the `db` instance, we create the Collections and anything needed.\n- The Dyna Mondo DB takes care when to run these Upgrade Methods.\n- The same Upgrade methods applied to Dynamic Collections \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faneldev%2Fdyna-mongo-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faneldev%2Fdyna-mongo-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faneldev%2Fdyna-mongo-db/lists"}