Giter VIP home page Giter VIP logo

cds-pg's Introduction

npm version Package Build

cds-pg - PostgreSQL adapter for SAP CDS (CAP)

This node module provides an adapter to the PostgreSQL database.

Current status

This is a first alpha version! It can connect to a PostgreSQL database and execute basic CRUD statements.

Please see CONTRIBUTING.md for how to contribute additional capabilities!

TODO

[X] implement basic SELECT|READ(~ OData GET)
[X] implement basic INSERT|CREATE(~ OData POST)
[X] implement basic UPDATE(~ OData PUT|PATCH)
[X] implement basic DELETE(~ OData DELETE)
[X] map OData to PostgreSQL vocabulary
[X] implement basic cds deployment
[X] use default query builders for UPDATE/DELETE
[ ] add support for full OData vocabulary
[ ] add advanced deployment model that supports delta handling/migrations
[ ] maybe add some PostgreSQL specific data type support
[ ] add more tests

usage in your CAP project

Add this package to your SAP Cloud Application Programming Model project by running:

npm install cds-pg

Then add this configuration to the cds section of your package.json:

  "cds": {
    "requires": {
      "db": {
        "kind": "postgres"
      },
      "postgres": {
        "impl": "cds-pg",
        "model": [
          "srv"
        ]
      }
    }
  }

For local development you can provide the credentials in the file default-env.json in the root folder of your project:

{
  "VCAP_SERVICES": {
    "postgres": [
      {
        "name": "postgres",
        "label": "postgres",
        "tags": [
          "postgres"
        ],
        "credentials": {
          "host": "localhost",
          "port": "5432",
          "database": "dbname",
          "user": "postgres",
          "password": "postgres"
        }
      }
    ]
  }
}

CDS deployment

With the command:

npx cds-pg deploy srv --to db

you can deploy all tables and views defined in your CDS model to the PostgreSQL DB specified in default-env.json. Initial data will also be filled from the provided .csv files following the approach described in Providing Initial Data. Be aware that the existing tables and views are deleted and then re-created according the CDS model.

Projects using cds-pg

Example project pg-beershop

cds-pg's People

Contributors

d-sooter avatar gregorwolf avatar larshp avatar mikezaschka avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.