on 2025 Nov 06 9:47 PM
Hello Experts,
Can you please help me with the difference between the events CREATE and INSERT? When should I use each one, and what is the best practice? Also, what is the standard sequence of invocation? Based on my debugging, it appears that whichever event handler is implemented first is the one invoked first.
this.before('CREATE', Properties, async (req) => {
}
this.before('INSERT', Properties, async (req) => {
}
Best regards,
Ramjee Korada
Request clarification before answering.
Hi Ramjee,
You can check the official CAP documentation here:
👉 https://cap.cloud.sap/docs/node.js/events
The docs explain the different event types such as CREATE, READ, UPDATE, DELETE, and custom events. However, CAP does not guarantee a fixed order of execution when multiple handlers (like CREATE and INSERT) are implemented for the same entity.
From practical experience, CREATE is the higher-level event that wraps the insert logic, and the order of execution you see is often due to how the handlers are registered in code, not a defined framework rule.
So the best practice is to use CREATE for general logic and reserve INSERT only for database-level customization.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.