Search

Databases

Class cds.DatabaseService and subclasses thereof are technical services representing persistent storage.

cds.DatabaseService class

class cds.DatabaseService extends cds.Service

cds.DatabaseService — Consumption

InsertResult (Beta)

  • On INSERT, DatabaseServices return an instance of InsertResult defined as follows:
    • Iterator that returns the keys of the created entries, for example:
      • Example: [...result] -> [{ ID: 1 }, { ID: 2 }, ...]
      • In case of INSERT...as(SELECT...), the iterator returns {} for each row
    • affectedRows: the number inserted (root) entries or the number of affectedRows in case of INSERT into SELECT
    • valueOf(): returns affectedRows such that comparisons like result > 0 can be used

      === can’t be used as it also compares the type

cds.DatabaseService — Configuration

Pool

Instead of opening and closing a database connection for every request, we use a pool to reuse connections. The pool configuration can be adjusted by setting the pool option, for example:

{
  "cds": {
    "requires": {
      "db": {
        "kind": "hana",
        "pool": {
          "max": 1400,
          "min": 100
        }
      }
    }
  }
}

Even though we provide a default pool configuration, we expect that each application provides its own based on its specific needs.

More to Come

This documentation is not complete yet, or the APIs are not released for general availability. There’s more to come in this place in upcoming releases.

Show/Hide Beta Features