You are not logged in.
Hi all. I'm new using Mormot and we're testing it. We would like the "GET" command to return all or some fields and not just the "ID" field. For example:
...
TTemporada = class(TSQLRecord)
private
fCode : string;
published
property Code : string index 30 read fCode write fCode;
end;
...
Request: GET http://localhost:8080/root/temporada
Result:
[
{
"ID": 1
},
{
"ID": 2
}
]
And we'd like to get the following:
[
{
"ID": 1,
"CODIGO": "Cod1"
},
{
"ID": 2,
"CODIGO": "Cod2"
}
]
Regards,
Sergio
Offline
Use method/interface based services instead the default orm implementation.
Offline
It works as documented.
See https://synopse.info/files/html/Synopse … #TITLE_259
You can use some optional URI arguments to the ORM REST request - see https://synopse.info/files/html/Synopse … #TITLE_560
But as macfly states, it is NOT the best option, for security reasons.
You would better encapsulate your queries into a service (method-based service or interface-based service), then disable the RESTful ORM on production.
Offline
Maybe this information should be in the documentation.
Default ORM Rest:
Best for tests or internal usage. Must be disabled for public access.
Interface based services:
Best for Delphi/FPC clients or when the client can follow the rules of the service.
Method bases services:
Best por ajax clients or when the service must follow the rules.
Last edited by macfly (2019-06-25 14:18:55)
Offline
Thank you for your responses and recommendations. Greetings.
Offline
@macfly
I have enhanced the documentation to make thinks for more, according to your proposal.
See https://synopse.info/files/html/Synopse … #TITLE_266
Offline
@ab
the link does not scroll the page to the appropriate chapter of the documentation, is it only happening for me?
Offline
Please try https://synopse.info/files/html/Synopse … l#TITL_204
And ensure you re-load the documentation page in your browser to get its latest content.
Offline
Thanks @ab for the attention of always.
It was excellent.
This is a question that seems to be recurring in the forum and something that I had some difficulty to understand as well.
PS: And best of all is that everything can be mixed, MVC + Method services + interface services, etc. on the same server.
Offline
Please try https://synopse.info/files/html/Synopse … l#TITL_204
And ensure you re-load the documentation page in your browser to get its latest content.
Thanks, this link works properly, previous not.
Offline