Combined Resources

Combined resources are resources whose attributes are combined and included in a containing resource. You define a resource as combined by selecting the Combined checkbox on the Create, Resources, Resource tab.

Combined resources must:
  • Be contained in another resource (it cannot be a top resource).
  • Contain only combined sub-resources.
  • Contain only attributes with names that do not conflict with the attributes of the containing resource, or of any other resource combined into the same resource.
  • Be a SQL resource of type Normal.
  • Not be a collection: at most one object is expected.
The attributes from the combined resources are read-only; you can send them back as part of a POST or PUT, but their values are ignored.

For more information about REST resources, including resource types, see Define Custom REST Resources.

B2B Example: Create a Combined Resource

In this example, you need to define an OrderItem, and Product table. You want a resource that, for each order item, shows the product name. You can:
  • Define a complex object by creating the following resources:
    • A top-level OrderItem resource.
    • A Product sub-resource with a product_name attribute.
  • Define a OrderItem combined resource with product_name attributes.
The following image shows the OrderItem combined resource, with the Combined checkbox selected, on the Create, Resources, Resource tab:

View and Process Data from Combined Resources

The resulting data from combined resources is easy to read and to process. The following code snippet illustrates the expected JSON result when you do not define a combined resource:

...
  "Order_DetailsList": [
    {
      "OrderID": 2000,
      "ProductID": 7,
      "UnitPrice": 30,
      "Quantity": 2,
      "isHealthy": true,
      "Amount": 60,
      "Discount": 0,
      "@metadata": {
        "href": "http://localhost:8080/rest/default/b2bderbynw/v1/OrderSummary.Order_DetailsList/2000~7",
        "checksum": "A:bf1bf24e035d8830"
      },
      "Product": {
        "ProductID": 7,
        "ProductName": "Uncle Bob's Organic Dried Pears",

        "@metadata": {
          "href": "http://localhost:8080/rest/default/b2bderbynw/v1/OrderSummary.Order_DetailsList.Product/7",
          "checksum": "A:b1ad26b6d1c32358"
        }
      }
...

The following code snippet illustrates the expected JSON result when you define a combined resource, where the combined metadata section lists the attributes originating from the combined resource:

...
  "Order_DetailsList": [
    {
      "OrderID": 2000,
      "ProductID": 7,
      "UnitPrice": 30,
      "Quantity": 2,
      "isHealthy": true,
      "Amount": 60,
      "Discount": 0,
      "ProductName": "Uncle Bob's Organic Dried Pears"
      "@metadata": {
        "href": "http://localhost:8080/rest/default/b2bderbynw/v1/OrderSummary.Order_DetailsList/2000~7",
        "checksum": "A:bf1bf24e035d8830",
        "combined": [
          "ProductName"
        ]
       },
...