Jump to:

22972 Posts in 11596 Topics by 2824 members

General Questions

SilverStripe Forums » General Questions » JSON request with related records

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

Page: 1
Go to End
Author Topic: 559 Views
  • Isidro
    Avatar
    Community Member
    4 Posts

    JSON request with related records Link to this post

    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?

  • Isidro
    Avatar
    Community Member
    4 Posts

    Re: JSON request with related records Link to this post

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

    559 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.