I have a mongodb document with below structure..
{
"key4" :
[
{"k1":"v1", "k2":"va1", "k3":"value1"},
{"k1":"v2", "k2":"va2", "k4":"name"},
{"k1":"v3", "k2":"va3"}
]
}
when i was updating this document with given structure..
{
"key4" :
[
{"k1":"v1", "k3":"val1"},
{"k1":"v2", "k3":"val2"},
{"k1":"v3", "k3":"val3"},
{"k1":"v4", "k3":"val4"}
]
}
i need output as..
{
"key4" :
[
{"k1":"v1", "k2":"va1", "k3":"val1"},
{"k1":"v2", "k2":"va2", "k3":"val2", "k4":"name"},
{"k1":"v3", "k2":"va3", "k3":"val3"},
{"k1":"v4", "k3":"val4"}
]
}
which means that if value of 'k1' exist in the new array, it should merge the only object of array into new. i am implementing this structure in clojure map.