mardi 17 mars 2015

update the _class property in all documents


Vote count:

0




I am using mongo with spring and I have the _class property in many documents in different collections, at some point I changed my package names and that caused errors with old documents that have the older package name in the _class property. what would be the best way to update the package name in the _class property in all the collections and documents ?


I managed to write a script that does the change for a specific collection ( it also requires recursion as some documents have some nested sub documents ). but I want a solution that would work for all collections.


I tried to just convert the document to a string replace the package name and convert back to json but that caused



_id: ObjectId("5500697dee854093136467ef")


to convert into



"_id" : {
"str" : "5500697dee854093136467ef"
}


Any simple way to achieve this kind of update task ?



asked 1 min ago

jacob

278






update the _class property in all documents

Aucun commentaire:

Enregistrer un commentaire