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.

General Questions

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

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

JSON request with related records


2 Posts   622 Views


28 October 2010 at 11:19pm Community Member, 4 Posts

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?


10 November 2010 at 11:17am Community Member, 4 Posts

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!?