-
Notifications
You must be signed in to change notification settings - Fork 150
feat: direct CRUD in both stacks #2406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -491,6 +491,7 @@ You can add your validation logic before the operation handler for either CRUD o | |
|
|
||
| <div id="query-data-draft-enabled" /> | ||
|
|
||
|
|
||
| ### Query Drafts Programmatically | ||
|
|
||
| To access drafts in code, you can use the [`.drafts` reflection](../../node.js/cds-reflect#drafts). | ||
|
|
@@ -500,6 +501,42 @@ SELECT.from(Books.drafts) //returns all drafts of the Books entity | |
|
|
||
| [Learn how to query drafts in Java.](../../java/fiori-drafts#draftservices){.learn-more} | ||
|
|
||
|
|
||
| ### Direct CRUD <Beta /> | ||
|
|
||
| With <Config>cds.fiori.direct_crud:true</Config>, creating or modifying active instances directly is possible without creating drafts. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same config for Node.js and Java?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one yes, because it affects compile to odata. but there will be an additional config for java, afaik. |
||
| This comes in handy when technical services without a UI interact with each other. | ||
|
|
||
| That is, you can then create and modify active instances directly: | ||
|
|
||
| ```http | ||
| POST /Books | ||
|
|
||
| { | ||
| "ID": 123 | ||
| } | ||
| ``` | ||
|
|
||
| ```http | ||
| PUT /Books(ID=123) | ||
|
|
||
| { | ||
| "title": "How to be more active" | ||
| } | ||
| ``` | ||
|
|
||
| For this, the default draft creation behavior by SAP Fiori Elements is redirected to a collection-bound action via annotation `@Common.DraftRoot.NewAction`. | ||
| The thereby freed `POST` request to draft roots without specifying `IsActiveEntity` leads to the creation of an active instance (as it would without draft enablement). | ||
|
|
||
| The feature is required to enable [SAP Fiori Elements Mass Edit](https://sapui5.hana.ondemand.com/sdk/#/topic/965ef5b2895641bc9b6cd44f1bd0eb4d.html), allowing users to change multiple objects with the | ||
| same editable properties without creating drafts for each row. | ||
|
|
||
| :::warning Additional entry point | ||
| Note that this feature creates additional entry points to your application. Custom handlers are triggered with delta | ||
| payloads rather than the complete business object. | ||
| ::: | ||
|
Comment on lines
+534
to
+537
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The is a warning regarding mass edit, not direct_crud, yes? |
||
|
|
||
|
|
||
| ## Use Roles to Toggle Visibility of UI elements | ||
|
|
||
| In addition to adding [restrictions on services, entities, and actions/functions](../security/authorization#restrictions), there are use cases where you only want to hide certain parts of the UI for specific users. This is possible by using the respective UI annotations like `@UI.Hidden` or `@UI.CreateHidden` in conjunction with `$edmJson` pointing to a singleton. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest we move this section to immediately after: https://pages.github.tools.sap/cap/docs/guides/uis/fiori#draft-choreography-how-draft-editing-works