I'm trying to convert the "interesse" array into a new object with 2 fields "term" which is the current array terms and a statistic value with the name "str" with a starting value of 0
as the following example.
my database currently has about 16KK entries so i'm trying to create some sort of function or routine to deal with it.
Original documents
{
"email" : "[email protected]",
"interesse" : [
"Calcados",
"Acessorios para viagem",
"Interesse em noticias sobre curiosidades"
],
"data" : "2017-01-30"
}
{
"email" : "[email protected]",
"interesse" : [
"Eletrodomesticos e portateis",
"Geladeiras"
],
"data" : "2017-01-30"
}
Result documents
{
"email" : "[email protected]",
"interesse" : [
{"term":"Calcados","str":0},
{"term":"Acessorios para viagem","str":0},
{"term":"Interesse em noticias sobre curiosidades","str":0}
],
"data" : "2017-01-30"
}
{
"email" : "[email protected]",
"interesse" : [
{"term":"Eletrodomesticos e portateis","str":0},
{"term":"Geladeiras","str":0},
],
"data" : "2017-01-30"
}
I was looking at arrayToObject.. but the function only transforms the entire array into a single object... what i want is to transform each value into new object...