apazureck / odatatools

OData Tools for vscode
24 stars 12 forks source link

How to convert query? #39

Open LucaGabi opened 5 years ago

LucaGabi commented 5 years ago

Hi,

If I have this query:

fetch(`http://localhost:5000/odata/
                    Doctors?$select=Name&
                    $filter=DoctorSpecializations/any()&
                    $expand=DoctorSpecializations(
                        $select=SpecializationId,Specialization;
                        $expand=Specialization($select=Name))`)

How to write it with the proxy lib?

Thanks!

apazureck commented 5 years ago

Did you check out the wiki? https://github.com/apazureck/odatatools/wiki/Usage-of-Proxy-Client

LucaGabi commented 5 years ago

Yes.. it dose not help me much .. I don't understand if I can do nested operations with the lib.

apazureck commented 5 years ago

That's a good question. I think you could use the custom query option for this and just paste your code in there, so like:

const comm = new MovieProxy("http://localhost:5000/odata", "Testproxy");
const result = comm.Doctors.Custom("$select=Name&$filter=DoctorSpecializations/any()&$expand=DoctorSpecializations($select=SpecializationId,Specialization;$expand=Specialization($select=Name))").Get();

And the semicolon is disturbing. You are sure that's a proper odata query?

Best practice is to start simple, just do one query at a time. It also may depend if your odata server allows all queries, like expand and select or the any function.

LucaGabi commented 5 years ago

Yes, no doubt it is correct. Thanks anyway.

apazureck commented 5 years ago

I think the proxy does not support filter functions with the function syntax. So custom query should do the trick anyway. Let me know if it worked. You may also be able to extend the outcome by editing the template.