0

I am new to Mongo & Ws02 DSS. Below is the update operation I have written to update the existing document in the Mcongo's llection named "inventory".

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

While all the simple operations works well, but I am getting the below nested exception for update :

java.lang.IllegalArgumentException: Too many parameters passed to query: {"currentStock" :"2"}

For simplicity, I have hard corded without using the param I have created, but still the update doesn't work. Can someone please help?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
sivabalan19
  • 91
  • 1
  • 1
  • 8
  • Can you show the result of a get query? – Bee Jul 20 '17 at 09:04
  • > db.inventory.find() { "_id" : ObjectId("596e79ad60b934a369266524"), "itemId" : "1", "itemName" : "Television-4k", "unitPrice" : "1400", "currentStock" : "77" } { "_id" : ObjectId("596e79bf60b934a369266525"), "itemId" : "2", "itemName" : "Laptop", "unitPrice" : "400", "currentStock" : "53" } { "_id" : ObjectId("596e7dad7353e34606463c37"), "itemId" : "4", "itemName" : "Refrigerator", "unitPrice" : "700", "currentStock" : "23" } { "_id" : ObjectId("596ef6327353e33b264b506c"), "itemId" : "3", "itemName" : "Mobile", "unitPrice" : "400", "currentStock" : "2" } – sivabalan19 Jul 20 '17 at 15:01
  • Adding the query : inventory.find() And Operation : – sivabalan19 Jul 20 '17 at 15:09
  • Do you get the same error if you remove `` part? – Bee Jul 20 '17 at 15:34
  • When i remove the param from the query & operations's call-query, the hard coded update is working well. Only when i use params, it is throwing "Too many parameters passed to query: {currentStock : '3'}". inventory.update({itemId:'3'}, {currentStock : '3'}) i am not sure why it is. – sivabalan19 Jul 20 '17 at 19:40
  • Please post your original query config. (i.e. with parameter) – Bee Jul 21 '17 at 05:23

1 Answers1

0

This should work, I think.

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