0

I am writing a query to find and update an array in a document, but mongo shell is not responding after running the update query using $set. The array in the document is not updated, and also no response is shown for any of the commands ran after update.

My update query looks as below,

db.TestFlowSteps.update(
  {"testFlowId":"23","testRunDetail.testRunDetailId":"1"},
  {$set: {'testRunDetail.$.applicationId':'5'}})
)

This is an example document:

{
   "_id":ObjectId("58c92abd43df987ae87e1c79"),
   "testFlowId":"23",
   "testRunDetail":[

      {
         "testRunDetailId":"1",
         "testRunId":"23",
         "applicationName":"APP",
         "applicationId":"41",
         "testCaseId":"818",
         "testCaseName":"Test123",
         "browserMode":"YES",
         "index":1,
         "edit":false
      }
   ]
}
Vince Bowdren
  • 8,326
  • 3
  • 31
  • 56
Rajesh
  • 13
  • 3
  • Can you add the sample document from your collection ? – s7vr Mar 19 '17 at 15:02
  • @Veeram added a sample document – Rajesh Mar 19 '17 at 16:15
  • You are missing closing parenthesis for set document. Try `db.TestFlowSteps.update( {"testFlowId":"23","testRunDetail.testRunDetailId":"1"}, {$set: {'testRunDetail.$.applicationId':'5'} } )` – s7vr Mar 19 '17 at 16:24
  • @Veeram, Thanks But its a type 'o' mistake from my side. mongo shell notifies this kind of syntax errors. No error has been displayed after running the query. – Rajesh Mar 20 '17 at 06:34
  • How many entries does your collection have? Are the fields you query for indexed? What is the output of `.explain`. Please edit your question accordingly. – Markus W Mahlberg Mar 20 '17 at 08:30

0 Answers0