code: private void installTransform(DatabaseClient client) {
      // this transform seeks orders associated with a single customer
      // record and injects the orders into the customer record
      String transform =
        "function transform_function(context, params, content) { " +
        "  var uri = context.uri; " +
        "  var customer = content.toObject(); " +
        "  var orders = cts.search(cts.andQuery([" +
        "    cts.collectionQuery('orders'), " +
        "    cts.jsonPropertyValueQuery('customerid', customer.id)" +
        "  ])); " +
        "  if ( fn.count(orders) > 0 ) { " +
        "    customer.orders = new Array(); " +
        "    for (let order of orders) { " +
        "      var customerOrder = order.toObject(); " +
        "      delete customerOrder.customerid; " +
        "      customer.orders.push(customerOrder); " +
        "    } " +
        "  } " +
        "  return customer; " +
        "}; " +
        "exports.transform = transform_function";
      ServerConfigurationManager confMgr = client.newServerConfigManager();
      TransformExtensionsManager transformMgr = confMgr.newTransformExtensionsManager();
      transformMgr.writeJavascriptTransformAs(transformName, transform);
    }
docs: /*
  Install the transform on the server which would find all the orders made by
  the customer and append all the orders information to the corresponding
  customer document.