npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

cds-mongodb

v1.0.1

Published

MongoDB (Mongoose) persistence adapter for SAP Cloud Application Programming Model

Readme

cds-mongodb

MongoDB (Mongoose) persistence adapter for SAP Cloud Application Programming Model (CAP).

cds-mongodb enables CAP applications to use MongoDB as a native persistence layer, providing a developer experience consistent with official CAP database services such as @cap-js/sqlite and @cap-js/hana.


Why cds-mongodb

SAP CAP is traditionally optimized for relational databases.
However, modern enterprise scenarios increasingly require document-oriented storage, especially for:

  • AI/ML workloads
  • Event-driven systems
  • Flexible schemas
  • High-ingestion data models

cds-mongodb bridges this gap without changing how developers write CDS models or services.


Key Features

  • Native CAP database service (no custom CRUD handlers required)
  • Persists CDS entities to MongoDB using Mongoose
  • Supports READ, CREATE, UPDATE, DELETE via CAP CQN
  • Supports managed CDS associations using MongoDB ObjectId references
  • Automatic association resolution via $expand (Mongoose populate)
  • cds deploy --to mongoose support
  • CSV seed data import from db/data/*.csv
  • Reusable npm package
  • Compatible with SAP BTP and local development

What This Is (and Is Not)

Supported

  • Standard CRUD operations
  • $expand for managed associations
  • CAP service exposure without custom handlers
  • Document-centric and AI-driven use cases

Not Supported (Current Version)

  • Draft-enabled entities
  • Complex CDS views and joins
  • Transaction semantics
  • Recursive or deep $expand
  • Advanced CQN operators

Installation

npm install cds-mongodb

Configuration

{
  "cds": {
    "requires": {
      "db": {
        "kind": "mongoose",
        "impl": "cds-mongodb",
        "credentials": {
          "url": "mongodb://localhost:27017/cap"
        }
      }
    }
  }
}

Or via environment variable:

export MONGO_URL=mongodb://localhost:27017/cap

Usage

CDS Model (db/datamodel.cds)

entity Authors {
  key ID   : UUID;
  name     : String;
  books    : Association to many Books;
}

entity Books {
  key ID    : UUID;
  title     : String;
  author    : Association to Authors;
}

Service (srv/service.cds)

service CatalogService {
  entity Authors as projection on Authors;
  entity Books   as projection on Books;
}

No custom handlers required.


Running Locally

cds deploy --to mongoose
cds run

CSV Seed Data

Place CSV files under:

db/data/

File name must match CDS entity name.


Association Handling

  • Stored as MongoDB ObjectId references
  • $expand translated to Mongoose populate
  • Expand depth limited to 1

Example:

GET /catalog/Authors?$expand=books

Compatibility Matrix

| Component | Version | |---------|---------| | Node.js | >= 18 | | @sap/cds | ^7.x | | MongoDB | 6.x, 7.x | | Mongoose | 8.x |


Logging & Errors

  • Uses CAP logging (cds.log)
  • Normalized CAP-style errors
  • No MongoDB internals exposed

License

Apache License 2.0


Disclaimer

This is an independent, community-driven project and is not an official SAP product.