cancel
Showing results for 
Search instead for 
Did you mean: 

Object orientation in CAP

msbike
Explorer
0 Kudos

Hello together,

I am new to CAP and I am wondering if there is an easy way to handle defined CDS models in an object orientated way so that I can define methods on those objects. My goal is to implement a central behavior of an object that can be used by services and background jobs.

Regards

Jens

Accepted Solutions (0)

Answers (2)

Answers (2)

martinstenzig
Contributor

Jens, I can only speak for Node.js, but there you have the ApplicationService object that your custom handlers extend. So you can build JensApplicationService, extend Application Service and have your handlers extend JenApplicationService.

...
export default class HcmCoreService extends cds.ApplicationService {
...
robinjayasinghe
Employee
Employee

Same applies to CAP Java. You can also express a certain amount of logic within CDS views. Benefit here would be that this logic is already executed on the DB layer. Drawback is that you need to be careful with that wrt. to performance when doing so. Other than that you can of course just implement handlers for your entities (or whole services) that would then be executed on corresponding events.

msbike
Explorer
0 Kudos

Martin and Robin, thanks for your answer. I will try this. Actually I will do try it with node.js.

vansyckel
Advisor
Advisor

Hi Jens and Martin,

Please also see our Actions API. We generate JS functions to call based on action definitions in your model.

Best,
Sebastian