From 60a99331ec38fb5e992165c63babb12408402a3e Mon Sep 17 00:00:00 2001 From: sjvans <30337871+sjvans@users.noreply.github.com> Date: Mon, 4 Aug 2025 09:50:37 +0200 Subject: [PATCH 1/2] req.subject ignores query options --- node.js/events.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/node.js/events.md b/node.js/events.md index c995785d4e..ca294d4a67 100644 --- a/node.js/events.md +++ b/node.js/events.md @@ -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) @@ -376,7 +379,7 @@ 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_**. From aab0fc2734d12cc57a64c5064ee3f179259048c4 Mon Sep 17 00:00:00 2001 From: sjvans <30337871+sjvans@users.noreply.github.com> Date: Mon, 4 Aug 2025 10:00:30 +0200 Subject: [PATCH 2/2] GET Books/201 vs GET Books?$filter=ID eq 201 --- node.js/events.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/node.js/events.md b/node.js/events.md index ca294d4a67..b19ea98875 100644 --- a/node.js/events.md +++ b/node.js/events.md @@ -381,6 +381,14 @@ DELETEfrom(req.subject) //> deletes the single target row > 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 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' }] } +```