1

My Mongo-DB document look as follows

{ "_id" : ObjectId("5c9b20b180c4a5698aa49281"), "arr" : [ 1, 2, 2, "23" ] }
{ "_id" : ObjectId("5c9b20b180c4a5698aa49282"), "arr" : [ 1, 2, 2, "23" ] }
{ "_id" : ObjectId("5c9b20b180c4a5698aa49283"), "arr" : [ 23, "234", 42, 24 
]}

i need to convert the single string element from "arr" array to int.

Lucifar
  • 43
  • 6
  • 1
    There is no way to convert without actually reading the documents in a loop and rewriting them, unless you actually can write to a completely new collection and use aggregate. If there's "billions" of documents, then they are probably on shards, so you could not do that anyway and could only write to a single "unsharded" collection – Neil Lunn Mar 29 '19 at 12:49
  • can you tell how can i do this with scanning whole docs NeilLunn – Lucifar Mar 29 '19 at 13:20
  • Does not matter if you have 1 or 1,000,00 elements to change. You loop the results and rewrite it. Still the same linked answer applies. – Neil Lunn Apr 01 '19 at 06:50
  • i dont know that much about mongo i just need the query to change these values @NeilLunn – Lucifar Apr 02 '19 at 07:03
  • That's what the link in the large box above your question is for. – Neil Lunn Apr 02 '19 at 07:50

0 Answers0