{"id":18695413,"url":"https://github.com/julianschmuckli/cap_mdb_handler","last_synced_at":"2026-04-30T02:35:01.223Z","repository":{"id":224438402,"uuid":"763214655","full_name":"julianschmuckli/cap_mdb_handler","owner":"julianschmuckli","description":"An SAP CAP extension to connect to any MongoDB instance.","archived":false,"fork":false,"pushed_at":"2024-02-26T11:32:35.000Z","size":76,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-14T04:41:47.585Z","etag":null,"topics":["cap","mongodb","sap","sap-cap"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/cap_mdb_handler","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/julianschmuckli.png","metadata":{"files":{"readme":"README.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-02-25T20:56:44.000Z","updated_at":"2024-02-25T23:04:05.000Z","dependencies_parsed_at":"2024-02-26T00:31:08.796Z","dependency_job_id":"ab1d7244-eb40-4c77-bd12-41d4ffc119e5","html_url":"https://github.com/julianschmuckli/cap_mdb_handler","commit_stats":null,"previous_names":["julianschmuckli/cap_mdb_handler"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/julianschmuckli/cap_mdb_handler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julianschmuckli%2Fcap_mdb_handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julianschmuckli%2Fcap_mdb_handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julianschmuckli%2Fcap_mdb_handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julianschmuckli%2Fcap_mdb_handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/julianschmuckli","download_url":"https://codeload.github.com/julianschmuckli/cap_mdb_handler/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/julianschmuckli%2Fcap_mdb_handler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32452739,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T22:27:22.272Z","status":"online","status_checked_at":"2026-04-30T02:00:05.929Z","response_time":57,"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":["cap","mongodb","sap","sap-cap"],"created_at":"2024-11-07T11:14:53.786Z","updated_at":"2026-04-30T02:35:01.203Z","avatar_url":"https://github.com/julianschmuckli.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SAP Cloud Application Programming Model (CAP) - MongoDB Handler\nAn unofficial SAP CAP extension to connect to any MongoDB instance.\n\n[![npm version](https://badge.fury.io/js/cap_mdb_handler.svg)](https://badge.fury.io/js/cap_mdb_handler)\n\n## Introduction\n\nThis project lets you connect to a MongoDB instance from a CAP service. It provides a simple way to read, create, update and delete documents in a MongoDB collection, which represents a CAP entity. The flexible nature of MongoDB allows you to store any kind of data, which can be accessed and manipulated using the CAP service.\n\n![Architecture](./docs/architecture.png)\n\nAll logos are trademarks of their respective owners.\n\n## Prerequisites\n- Node.js\n- MongoDB instance\n- SAP Cloud Application Programming Model (CAP)\n- SAP Business Application Studio (BAS) or \n    - Visual Studio Code (VSCode) with the SAP Business Application Studio Extension Pack installed\n\n\n## Installation\n```bash\nnpm i cap_mdb_handler\n```\n\n## Usage\nTo use the library now, we need to add the following code to the `srv/service.ts` file of your CAP project.\n\n```typescript\nimport type { Request } from \"@sap/cds/apis/services\"\nimport cds = require('@sap/cds');\n\n// 1. Import the MDBHandler\nimport MDBHandler from \"cap_mdb_handler\";\n\nrequire('dotenv').config();\n\nmodule.exports = cds.service.impl(async function () {\n\n    // 2. Create a new instance of the MDBHandler\n    const oHandler = new MDBHandler(process.env[\"MONGO_URL\"], process.env[\"MONGO_DB\"]);\n\n    // 3. Register the event handlers\n    this.on('READ', '*', async (req : Request) =\u003e {\n        return await oHandler.read(req);\n    });\n\n    this.on('CREATE', '*', async (req : Request) =\u003e {\n        return await oHandler.create(req);\n    });\n\n    this.on('UPDATE', '*', async (req : Request) =\u003e {\n        return await oHandler.update(req);\n    });\n\n    this.on('DELETE', '*', async (req : Request) =\u003e {\n        return await oHandler.delete(req);\n    });\n});\n```\n\n## Additional Configuration\nThe MDBHandler requires the following environment variables to be set:\n- `MONGO_URL`: The URL of the MongoDB instance (beginning with `mongodb://` or `mongodb+srv://`)\n- `MONGO_DB`: The name of the database to connect to","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulianschmuckli%2Fcap_mdb_handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjulianschmuckli%2Fcap_mdb_handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulianschmuckli%2Fcap_mdb_handler/lists"}