I have the following linked entities:
For example, this is what you might see in the database:
To get all of the data, I'm currently doing this:
I have to parse many, many calls to the server because the objects are queried like this:
However, it would be a lot less load on my server if I could get all of that data at once. It would also be a big improvement if I could get the project object associated with each timesheetData object while also getting the timesheetData object. It would drastically reduce the number of calls. I can't figure out how to do any of that, though.
Ideally, I would be able to do this:
I see this in application/Espo/Resources/routes.json:
It looks like 'listLinked' is the action that queries linked objects. Is there a way to use that action to query the parent object AND all of the child objects at the same time?
Code:
Timesheet TimesheetData (many-to-one relationship with Timesheet) Project (one-to-many relationship with TimesheetData)
Code:
Timesheet0 TimesheetData0 Project0 TimesheetData1 Project4 TimesheetData2 Project5 Timesheet1 TimesheetData3 Project10 TimesheetData4 Project5 TimesheetData5 Project0
Code:
// Get list of timesheets GET /timesheet //Get the timesheetData objects that are linked to a timesheet object GET /timesheet/{id}/timesheetData // Get the project object that is linked to a timesheetData object GET /timesheetData/{id}/project
Code:
timesheets = get Timesheet objects from API (GET /timesheet) for each timesheet timesheetDatas = get TimesheetData objects from API (GET /timesheet/{id}/timesheetdata) foreach timesheetData project = get Project objects from API (GET /timesheetData/{id}/project)
However, it would be a lot less load on my server if I could get all of that data at once. It would also be a big improvement if I could get the project object associated with each timesheetData object while also getting the timesheetData object. It would drastically reduce the number of calls. I can't figure out how to do any of that, though.
Ideally, I would be able to do this:
Code:
GET timesheet with all timesheet/id/timesheetData and timesheet/id/timesheetData/id/project objects
PHP Code:
311 {
312 "route":"/:controller/:id/:link",
313 "method":"get",
314 "params":{
315 "controller":":controller",
316 "action":"listLinked",
317 "id":":id",
318 "link":":link"
319 }
320 }
It looks like 'listLinked' is the action that queries linked objects. Is there a way to use that action to query the parent object AND all of the child objects at the same time?
Comment