简体   繁体   English

WSO2 DSS解析mongoDB查询结果

[英]WSO2 DSS Parsing mongoDB query result

I try to connect to mongoDB using WSO2 DSS and its mongoDB data source and present the result via a service. 我尝试使用WSO2 DSS及其mongoDB数据源连接到mongoDB,并通过服务显示结果。 When setting the output mapping for a simple query result I cannot access the individual objects attributes. 为简单查询结果设置输出映射时,我无法访问单个对象的属性。 The only way to access the result is through a "virtual" column "document". 访问结果的唯一方法是通过“虚拟”列“文档”。 For instance for a query like this: 例如对于这样的查询:

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

I get results like this: 我得到这样的结果:

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

However I would like to map the field1 directly to the "_id" attribute. 但是,我想直接将field1映射到“ _id”属性。 Unfortunatelly I am unable to figure out how? 不幸的是我不知道怎么办? The samples in documentation are not much help in this. 文档中的示例对此没有太大帮助。

Try this: 尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM