Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

JSON request with related records


Go to End


2 Posts   1093 Views

Avatar
Isidro

Community Member, 4 Posts

28 October 2010 at 11:19pm

I'm working on a project and did already developed a few classes interrelated between them. Now I'm working in some ajax requests using JSON.

AFAIK these request return the main object and links to related objects, so we need to perform other requests to get some of the related data. For the sake of efficiency I would like to get, at least, part of the information of related records inside of the first request. Something like a Join query with the related records or part of then in the table view.

My app has an Alert class where issues are stored. Each Alert belongs to a Device:

Alert{Id, Message} *---1 Device {Id, SerialNumber, Name, ...}

So when I list an Alert I would like to see at least the Device name (a property of the Device).

To list Alerts I'm using /api/v1/Alert/.json

Is this possible somehow?

Avatar
Isidro

Community Member, 4 Posts

10 November 2010 at 11:17am

I guess I didn't explain myself correctly. I need to query a class and would like to list the properties of that class and data from related records.

I have a class relationship between "Instalation" class and "Device" class of type one-to-many. I would like to show for each Instalation instance at least the directly related data in the Device class instances. when using the rest api I get the Instalation instance and links to Devices related to this Instalation.

Is there any way to instruct Rest to show the related data as objects instead of links!?