cancel
Showing results for 
Search instead for 
Did you mean: 

DEPRECATED: req._queryOptions what to use to extract from query parameters?

kaizen9
Explorer
0 Kudos
158

Hello CAPlers,

I have productive use case to implement pagination with $skip, $top, $count from query parameter.

I must use functions which returns array of array of entity. Any pagination examples would be great to refer how the slicing logic is handled.
What should I use to make it work? 

When I use:

const { $top, $skip } = req._queryOptions || {};
I got 
------------------------------------------------------------------------------
DEPRECATED: req._queryOptions
Configuration req._queryOptions is deprecated and will be removed in upcoming releases!
------------------------------------------------------------------------------
Is there any documentation where it is mentioned? or maybe I missed
https://cap.cloud.sap/docs/node.js/events#cds-request

Please support. Thanks. 
 
View Entire Topic
Dinu
Active Contributor

try the following:

const { rows:$top, offset:$skip } =  req.query.SELECT.limit

* correction 22 April 2025 

kaizen9
Explorer
0 Kudos

Hi Dinu, thanks for response but not sure what you mean. I cannot even use the above property -> 

console.log("Test:", req.query.limit);

and got below error: [cds] - ️Uncaught TypeError: Cannot read properties of undefined (reading 'limit')
But using "req.http?.req?.query" works for me now.

Dinu
Active Contributor
0 Kudos
I have corrected the suggestion above; limit is from SELECT. For sample look at https://github.com/SAP-samples/cloud-cap-samples/blob/7d170eed734d7a6b65f773a7de5b31a47eb5f3eb/books...