I'm trying to build a project in MongoDB (my first project). I have the following structure :
{
"_id" : 1,
"week" : "1",
"Unit" : {
"Name" : "Area1",
"Name sub" : "Area1",
"Center name" : "Fuysam",
"Center type" : "Branch",
"Perm" : {
"GOP sales" : 6,
"GOP recruiters" : 2,
"GOP permmanent" : 1,
"GOP admins" : 6,
"GOP coordinator" : 2,
"GOP support" : 1,
"GOP others" : 0
},
"Plan" : {
"Temps New" : 26,
"OU New" : 21,
"Temps Lost" : 5,
"OU Lost" : 7,
"Current week" : 128,
"Outsourcing" : 332,
"L Clients" : 351,
"M Clients" : 65,
"S Clients" : 44,
"Position closed" : 1
}
}
Is it posible to add a Total field in every object in order to add automatically all of my fields ? (My fields number is dynamic, in week 2 I may have 5 fields, in week 3 I may have 9 fields and so on.) Something like this :
"Perm" : {
"GOP sales" : 6,
"GOP recruiters" : 2,
"GOP permmanent" : 1,
"GOP admins" : 6,
"GOP coordinator" : 2,
"GOP support" : 1,
"GOP others" : 0,
"GOP Total" : "GOP sales" + "GOP recruiters" + "GOP permmanent" + "GOP admins"......
}
If it is possible to do this, can you give me an example ? Thank you very much.