If you want to use mongo to do this, try this query:
db.collection.aggregate([
{
"$match": {
"id": 0
}
},
{
"$set": {
"appartamento.ids_stile": {
"$split": [
"$appartamento.ids_stile",
","
]
},
"appartamento.ids_personaggi": {
"$split": [
"$appartamento.ids_personaggi",
","
]
}
}
},
{
"$project": {
"appartamento.ids_stile": {
"$map": {
"input": "$appartamento.ids_stile",
"as": "newArray",
"in": {
"$convert": {
"input": "$$newArray",
"to": "int",
}
}
}
},
"appartamento.ids_personaggi": {
"$map": {
"input": "$appartamento.ids_personaggi",
"as": "newArray",
"in": {
"$convert": {
"input": "$$newArray",
"to": "int",
}
}
}
},
"appartamento.nome": 1,
"appartamento.via": 1
}
}
])
Basically is get the document you want (I've used appartamento.nome but you can match by _id or whatever you want).
Then, modify the fields using $set and $split to create an string array dividied by ','.
After that project the fields overwriting these two with a new array using $map where each value from string array now is converted to int.
Example here
Edit:
To do that with many documents, only is necessary remove the $match stage.
Example here