loopback icon indicating copy to clipboard operation
loopback copied to clipboard

Cascading Updates from Compound Documents to their corresponding Models

Open tonysoft opened this issue 12 years ago • 3 comments

If I retrieve some Entity and "include" some of its related Entities as in this sample Document below, I can Data Bind this on the client into some form with no knowledge or concern about the Model Relationships. See the sample Compound Doc below.

If I display all of this hierarchy in an Edit Form and I change the "name" of the Highest Level Entity but also edit some of the information for one or more of the "cars" in the Document, when I update the High Level Entity, it would be great to automatically fan out the updates to the Related Entities. An ORM (which shall remain nameless here) that I used in a prior project did this and greatly simplified the Client Side Code. This Cascaded or Fanned Out Update feature could even write the Entities out across various Data Sources. It has been mentioned to me that some complications regarding restricted Write Access to some of the Child Models might circumvent some security but those issues should be resolvable.

This sort of feature truly helps isolate the Front End Developer from having knowledge about the Model Relationship details. Prior to refactoring the ORM in my prior project, we had to have the Cascading Update on the Client (or Server) but had to call multiple REST methods to accomplish the updates. Our code was simplified by this feature.

Also, if you leave "id" out of the nested Entities, it would "Create" new nested Entities and formalize the relationship to the Parent Entity. Although it is not possible with "include" to retrieve Compound Documents more than one level deep, if the Client builds Multi-Level Documents (2 levels deep or more) the Create or Update operations would recurse through the Document and Create or Update all of the Entities in the Document Hierarchy.

  {
    "id": "2",
    "name": "TestRes2",  // Changed this from "Test"
    "cars": [
      {
        "id": "82",
        "vin": "d7e7088a-2e19-4634-8fe9-b17126c8f786",
        "year": 2013,
        "make": "Dodge",
        "model": "RAvalon",  // Changed this from "Avalon"
        "image": "/images/car/car_4.jpg",
        "carClass": "pickup",
        "color": "yellow",
        "dealerId": "e9429717-a670-4ba1-885c-c11a3c222d98"
      },
      {
        "id": "83",
        "vin": "c6072e86-d558-4b00-8c9d-addca815ed90",
        "year": 2013,
        "make": "Toyota",
        "model": "Titan",
        "image": "/images/car/car_1.jpg",
        "carClass": "fullsize",
        "color": "yellow",
        "dealerId": "e9429717-a670-4ba1-885c-c11a3c222d98"
      }
    ]
}

tonysoft avatar Sep 24 '14 23:09 tonysoft

Hy there, is any news about upserting child/related models?

mariohmol avatar Dec 02 '15 15:12 mariohmol

Hi guys, Any news on this feature?

fuzzball1980 avatar May 02 '16 15:05 fuzzball1980

LoopBack version 3 is in LTS, we won't be adding any new features.

bajtos avatar Nov 12 '19 16:11 bajtos