Skip to content

Commit 3a230c6

Browse files
authored
req.subject doesn't contain filter condition (#1974)
1 parent 32a9b79 commit 3a230c6

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

node.js/events.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,16 @@ It can be used as input for [cds.ql](cds-ql) as follows:
352352

353353
```js
354354
SELECT.one.from(req.subject) //> returns single object
355-
SELECT.from(req.subject) //> returns one or many in array
356-
UPDATE(req.subject) //> updates one or many
357-
DELETE(req.subject) //> deletes one or many
355+
SELECT.from(req.subject) //> returns one or all in array
356+
UPDATE(req.subject) //> updates one or all
357+
DELETE(req.subject) //> deletes one or all
358+
```
359+
It contains the path of the request without the filter condition. To include the filter use:
360+
```js
361+
this.before ('UPDATE', Incidents, async req => {
362+
let filter = await SELECT.from (req.subject).where(req.query.UPDATE.where) //> adds filter from the request
363+
let customFilter = await SELECT.from (req.subject).where(req.query.UPDATE.where).where `status.code = 'C'` //> adds filter from the request and custom filter
364+
})
358365
```
359366

360367
It's available for CRUD events and bound actions.

0 commit comments

Comments
 (0)