Skip to Content
1
Jun 30, 2019 at 04:53 PM

HANA XS Advanced: New CD&S Entity (Local SQLite) + Node.js -> implement action | function in service

216 Views Last edit May 21, 2020 at 04:25 PM 2 rev

recently found out that CDS has now become CD&S. Made this wonderful tutorial

Everything is working. I want to add function or action in the following service

using my.bookshop as my from '../db/data-model';


service Catalog2Service {
  entity Books @readonly as projection on my.Books;
  entity Authors @readonly as projection on my.Authors;
  entity Orders as projection on my.Orders;


// How to implement ?
  action applyProductDiscount ( productID:Integer, reason:String );
  function getApprovalStatus(customerID:Integer) returns Boolean;
}

The official documentation contains an example for JAVA annotations

How to implement it for node.js in new cd&s?

in .on() method?

    srv.on( 'applyProductDiscount', function(){
      console.log('11111111111')
    });


    srv.on( 'getApprovalStatus', function(){
      console.log('11111111111')
    });

None of them works.

Can not find the example for local SQLite in node.js. (with cds console app)

PS

Not interested in Cloud Hana example in Node.js module with express