【问题标题】:Too many parameters passed to query: {"currentStock" :#}传递给查询的参数太多:{“currentStock”:#}
【发布时间】:2017-07-21 13:37:15
【问题描述】:

我是 Mongo 和 Ws02 DSS 的新手。下面是我编写的更新操作,用于更新 Mcongo 的 llection 中名为“inventory”的现有文档。

 <query id="mongoUpdate" useConfig="localMongo1">
      <expression>inventory.update({"itemId":"3"},{"currentStock" :"2"})</expression>
     <param name="itemId" sqlType="STRING"/>
 </query>

虽然所有简单的操作都运行良好,但我得到了下面的更新嵌套异常:

java.lang.IllegalArgumentException:传递给查询的参数过多:{“currentStock”:“2”}

为简单起见,我在没有使用我创建的参数的情况下进行了硬连接,但更新仍然不起作用。有人可以帮忙吗?

【问题讨论】:

  • 你能显示一个get查询的结果吗?
  • > db.inventory.find() { "_id" : ObjectId("596e79ad60b934a369266524"), "itemId" : "1", "itemName" : "Television-4k", "unitPrice" : “1400”,“currentStock”:“77”} {“_id”:ObjectId(“596e79bf60b934a369266525”),“itemId”:“2”,“itemName”:“笔记本电脑”,“unitPrice”:“400”,“currentStock” ":"53"} {"_id":ObjectId("596e7dad7353e34606463c37"),"itemId":"4","itemName":"冰箱","unitPrice":"700","currentStock":"23"} {“_id”:ObjectId(“596ef6327353e33b264b506c”),“itemId”:“3”,“itemName”:“Mobile”,“unitPrice”:“400”,“currentStock”:“2”}
  • 添加查询:inventory.find() 和操作:
  • 如果你删除&lt;param name="itemId" sqlType="STRING"/&gt; 部分,你会得到同样的错误吗?
  • 当我从查询和操作的调用查询中删除参数时,硬编码更新运行良好。只有当我使用参数时,它才会抛出“传递给查询的参数过多:{currentStock:'3'}”。 inventory.update({itemId:'3'}, {currentStock : '3'}) 我不知道为什么会这样。

标签: mongodb wso2 wso2dss dss


【解决方案1】:

我认为这应该可行。

<query id="mongoUpdate" useConfig="localMongo1">
    <expression>inventory.update({"itemId":#},{"currentStock" :"2"}, true))</expression>
     <param name="itemId" sqlType="STRING"/>
</query>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-03-08
    • 1970-01-01
    • 1970-01-01
    • 2017-09-27
    • 2014-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多