【问题标题】:WSO2 DSS Parsing mongoDB query resultWSO2 DSS解析mongoDB查询结果
【发布时间】:2015-04-19 14:13:49
【问题描述】:

我尝试使用 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”属性。不幸的是,我无法弄清楚如何?文档中的示例对此没有太大帮助。

【问题讨论】:

    标签: mongodb mapping wso2 dss


    【解决方案1】:

    试试这个:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-23
      • 1970-01-01
      • 1970-01-01
      • 2022-08-03
      相关资源
      最近更新 更多