#1 2015-12-22 14:21:27

AOG
Member
Registered: 2014-02-24
Posts: 490

Root response without table ID

I am working on a webclient with SAPUI5.
SAPUI5 can work very nice with a REST server (as mORMot).

At the moment, the mORMot responds with a list of ID's when a table is requested through REST.
E.g.

http://localhost:8080/root/SampleRecord

gives as result:

[{"ID":1},{"ID":2},{"ID":3},{"ID":4}]

In some cases, SAPUI5 wants more from a root request (for fast master/detail apps).

So, would it be possible to add some custom fields (e.g. FirstName, LastName) into the root request.
At the moment, the mORMot does

SQLSelect := 'RowID'; // if no select is specified (i.e. ModelRoot/TableName)

Or should I make my own changes into TSQLRestServerURIContext.ExecuteORMGet ?

I also tried to make an overloaded version of the root request with a dedicated method, but failed.

Offline

#2 2015-12-22 15:32:42

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 334

Re: Root response without table ID

try this:

http://localhost:8080/root/SampleRecord/?select=FirstName,LastName

Esteban

Offline

#3 2015-12-22 15:57:08

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: Root response without table ID

Thanks !
This works as expected !!
I will use this.

However, some tuning of the bare root response would remain welcome (field-list, '', '*').

Offline

#4 2015-12-22 17:00:33

EMartin
Member
From: Buenos Aires - Argentina
Registered: 2013-01-09
Posts: 334

Re: Root response without table ID

I don't understand you.

?select=field1,field2,fieldN => field list
?select= or select='' => list all fields except blobs
?select=* => list all fields including blobs

is not it enough four you ?


Esteban

Offline

#5 2015-12-22 18:57:06

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: Root response without table ID

Tried all, and all work as expected.
So, for me, everything is ok !

It is just that I wanted to be able to get a custom reply when asking for a plain (table) root.
AFAIK, there is no real standard reply on a plain root request.
And, at the moment, I am not able to change the default behavior of mORMot: reply with ID's.

My goal: have a web-front-end that can work with many types of REST-servers.
Many other REST-servers do give more than just ID's when asking for root.

But again, I am happy with the solution you provided !

Offline

#6 2015-12-28 08:45:47

AOG
Member
Registered: 2014-02-24
Posts: 490

Re: Root response without table ID

Another question, related to this one.

The mORMot response for a root request without any table of whatever, is a nice

{
"errorCode":400,
"errorText":"Bad Request"
}

When using OData services, the root request gives a table overview.
E.g.
http://services.odata.org/V3/OData/OData.svc/
gives a nice overview of the available tables in the model

I also found an old thread about OData: http://synopse.info/forum/viewtopic.php?pid=2621#p2621

Would it be an idea (or feature request) to add some more info into the bare root request: a JSON / XML overview of the model ?
Would be usefull for me ...

Offline

Board footer

Powered by FluxBB