cancel
Showing results for 
Search instead for 
Did you mean: 

CAP CDS NodeJS limit result of query in on("READ") handler

ClaudioBanfi
Explorer
0 Kudos

Hello everyone,

we have a cap in nodejs that, at the user access, the main entity must be filtered based on user profile (a data from SF).

To achieve this we filtered the query result in on("READ") handler but we realized that the query is limited to 20 records but there are many others in table.

Is there a way to get all records of the entity and not only the first 20?

Below the code

Thank you

Kind regards

Claudio

tobias_steckenborn
Active Participant
0 Kudos

As a side note: Why are you awaiting the next function in the first line of your „on“ function? This executes the middleware succeeding the current middleware and doesn’t really seem to be what you should be relying for for your results?

Why aren’t you filtering in the after function?

Accepted Solutions (0)

Answers (1)

Answers (1)

tobias_steckenborn
Active Participant

Hey Claudio,

Do you want to get more results in that specific request or all requests made to the entity? For that request you could add the $top parameter to your call. For every request to that service or entity you might annotate it with „@cds.query.limit.default:20“. Raise the 20 to the (reasonable) number of results you want to receive.

ClaudioBanfi
Explorer
0 Kudos

Hi Tobias,


thank you for your answer, I have to read all records of the entity because I need to filter all of them based on the user's profile. However we found a solution in another way.

Thank you again!

Kind Regards

Claudio