on 11-27-2023 9:19 AM
When developing CAP CDS for Node.js I regularly had Custom Handlers in which I needed to read some part of the req.query object to make some other backend calls, sometimes I even had to modify the pre-generated queries so that they would properly work on a backend.
Let's take a look on what changed with CDS(here version 7.4.0)
As you can see, req.query.SELECT only contains a from section. Some other params like filter, limit and orderBY are not in this query object, but in Symbol(Original). -Why?
This makes developing with CAP a bit more confusing and more difficult for me.
For Example last week I had accessed a filter with req.req.query.$filter and tried to parse those filter back to CQL, so I could modify and then reattach it to the query parameters. But this doesn't seem like a good Practice
Are there new Best Practices when working with req.query in Custom Handlers using the newer CDS versions? How can I Access req.query.Symbol(Original) in my custom handlers (something like req.query.Symbol(Original) or req.query.['Symbol(Original'] doesnt work)?
Any Guidance or reference to documentation would be massively helpful.
Hi michaelschmid03 ,
You must not access Symbol(original), this is not public API.
Your handler must only take care of req.query, as is.
Note: Some properties might be part of the prototype chain.
Best regards,
David
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry for bothering you again david.kunz2 , I realize that this would work fine in the case of odata services, but in some cases I also have rest services or odata services that aren't obeying all typical odata conventions, So in these cases that wouldn't be an option right? I failed to mention this in my initial question.
Hi david.kunz2,
I have the exact same question. Could you please explain what you meant by `If there's some property missing, your handler must not take that property into account.` ?
How do I access the parsed filters etc.? Why does CAP assumes that my business logic doesn't need the passed filters?
Br, Ekansh
User | Count |
---|---|
77 | |
9 | |
9 | |
7 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.