1

我尝试使用 WSO2 DSS 及其 mongoDB 数据源连接到 mongoDB,并通过服务呈现结果。为简单查询结果设置输出映射时,我无法访问单个对象属性。访问结果的唯一方法是通过“虚拟”列“文档”。例如对于这样的查询:

<query id="mongo_find" useConfig="mongo_ds">
   <expression>things.find()</expression>
   <result outputType="json">
   {
      "entries": {
         "entry": [
             {
                "field1": $document
             }
         ]
      }
   }
   </result>
</query>

我得到这样的结果:

<entry>
   <field1>
      { "_id" : { "$oid" : "54e489adb4ca0903f9675824"} , "x" : 3.0}
   </field1>
</entry>

但是我想将 field1 直接映射到“_id”属性。不幸的是,我无法弄清楚如何?文档中的示例对此没有太大帮助。

4

1 回答 1

0

尝试这个:

<query id="mongo_find" useConfig="mongo_ds">
   <expression>things.find()</expression>
     <result outputType="json">
      {
       "entries": {
         "entry": [
            {
               "field1": $document._id
            }
         ]
       }
     }
    </result>
</query>
于 2016-11-19T16:25:34.490 回答