I have a use case in which I need to copy the whole object data to another object without creating an inner object. i.e, object inside the object.
For example,
obj_1 = {
"_id": "SPool",
"w1": 60,
"w2": 150
}
obj_2 = {
"_id": "SPool",
"w1": 30,
"w2": 120
}
As both objects having same _id
fields, I want to copy the data of obj-2
to obj-1
and want to find the difference between the 2 objects like the following.
obj_1 = {
"_id": "SPool",
"w1": 60,
"w2": 150,
"obj_2" : {
"w1": 30,
"w2": 120
}
"diff": {
"w1": 30,
"w2": 30
}
}
Is it possible to do like this?