Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions node.js/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,10 @@ For bound custom operations, `req.query` contains the query to the entity on whi
### . subject {.property}

Acts as a pointer to the instances targeted by the request.
For example for the equivalents of inbound requests addressing _single rows_ like these:
The _target_ of a request is equivalent to the [`source` of a query](../cds/cqn#from).
That is, additional query options, such as CQL's `.where()` or OData's `$filter`, are not considered.

For example, for the equivalents of inbound requests, addressing _single rows_ like these:

```js
AdminService.read(Books,201)
Expand Down Expand Up @@ -376,8 +379,16 @@ DELETEfrom(req.subject) //> deletes the single target row

> [!warning]
> You can use `req.subject` in custom handlers for inbound `READ`, `UPDATE` and `DELETE` requests, as well as in _bound_ actions, addressing **_single rows_**.
> **You can't use it** reasonably in custom handlers for `INSERT` requests or other requests addressing **_multiple row_**.
> **You can't use it** reasonably in custom handlers for `INSERT` requests or other requests addressing **_multiple rows_**.

The following example further illustrates the difference between request target and additional query options:

```js
// GET Books/201
req.subject = { ref: [{ id: 'AdminService.Books', where: [{ ref: ['ID']}, '=', { val: 201 }] }] }
// GET Books?$filter=ID eq 201
req.subject = { ref: [{ id: 'AdminService.Books' }] }
```



Expand Down