Marklogic模板驱动提取:如何在Javascript模板中定义可空?

时间:2017-12-19 05:31:56

标签: javascript marklogic

如何指定架构中的列应该可以为空?

我尝试添加一个可以为空的属性:

var myFirstTDE = xdmp.toJSON(
  {
    "template": {
      "context": "/match",
      "collections": ["source1"],
      "rows": [
        {
          "schemaName": "soccer",
          "viewName": "matches",
          "columns": [
            {
              "name": "id",
              "scalarType": "long",
              "val": "id",
              "nullable": 0
            },
            {
              "name": "document",
              "scalarType": "string",
              "val": "docUri"
            },
            {
              "name": "date",
              "scalarType": "date",
              "val": "match-date"
            },
            {
              "name": "league",
              "scalarType": "string",
              "val": "league"
            }
          ]
        }
      ]
    }
  }
);

tde.validate( 
  [myFirstTDE]
);

但这给了我一个模板错误:

"message": "TDE-INVALIDTEMPLATENODE: Invalid extraction template node: fn:doc('')/template/array-node('rows')/object-node()/array-node('columns')/object-node()[1]/number-node('nullable')"

对于使用XQuery定义的模板,可以将nullable添加到列中:

<column>
  <name>ISSN</name>
  <scalar-type>string</scalar-type>
  <val>Journal/ISSN</val>
  <nullable>true</nullable>
</column>

如何使用JS / Json做同样的事情?

1 个答案:

答案 0 :(得分:2)

使用"nullable": true代替零..

HTH!