makeReferenceObject中的协调流-如何使用对象引用?

时间:2018-10-28 14:11:16

标签: marklogic marklogic-dhf

在有关协调产品和订单的DHF教程中,使用SKU通过引用将产品包括在订单中:

https://marklogic.github.io/marklogic-data-hub/tutorial/harmonizing-order-data/

// or a reference to a Product
products.push(makeReferenceObject('Product', order.sku));

...

function makeReferenceObject(type, ref) {
  return {
    '$type': type,
    '$ref': ref
  };
}

统一订单记录的示例:

"Order": {
  "id": 1,
  "products": [
    { "Product": {
      "$type": "Product", 
      "$ref": "12345"
    }},
    { "Product": {
      "$type": "Product", 
      "$ref": "54321"
    }}
  ],
  "price": 100
}

现在我们如何在订单记录中使用产品对象引用? entity service之类的es.instanceJsonFromDocument内置函数是否应该能够解析引用并将产品信息合并到输出中?还是对开发人员实施自己的自定义逻辑的参考?

1 个答案:

答案 0 :(得分:0)

我最终在实体服务文档中找到了该信息。它指出,实体服务API会将这些外部引用简单地视为字符串。

  

不对外部参考值进行验证。当您使用Entity Services API生成代码和其他工件时,该引用将被视为不透明字符串。

https://docs.marklogic.com/guide/entity-services/models#id_15972