Hello,
I have a document as given below:
{
“d”: {
“depnum”: “98”,
“dept_description”: “Settlements”,
“hotelnum”: “380”,
“id”: “dept380”,
“subdepartments”:
[
{
“addons”:
[
{
“adddepnum”: 1,
“addpercent”: 13,
“addsubdepnum”: 15,
“addtype”: “A”
},
{
“adddepnum”: 2,
“addpercent”: 13,
“addsubdepnum”: 14,
“addtype”: “B”
}
],
“descchangeflag”: “N”,
“subdepnum”: 1,
},
{
“descchangeflag”: “N”,
“subdepnum”: 2,
}
],
“summarize”: “N”,
“type”: “department”
}
}
Now, I want to add an attribute. Precisely, I would like the document to be in the following manner:
{
“d”: {
“depnum”: “98”,
“dept_description”: “Settlements”,
“hotelnum”: “380”,
“id”: “dept380”,
“subdepartments”:
[
{
“addons”:
[
{
“adddepnum”: 1,
“addpercent”: 13,
“addsubdepnum”: 15,
“addtype”: “A”
},
{
“adddepnum”: 2,
“addpercent”: 13,
“addsubdepnum”: 14,
“addtype”: “B”
}
],
“descchangeflag”: “N”,
“subdepnum”: 1,
},
{
“descchangeflag”: “N”,
“subdepnum”: 2,
}
],
“new_field”: “dummy value”
“summarize”: “N”,
“type”: “department”
}
}
Please suggest a way to add the attribute using N1QL