Hi,
I have below Json data in the document name “abcd_2_15667:0” on the Bucket: admin, Scope : _default and Collection : server.
{
“service”: {
“id”: “15667:0”,
“serviceActionRequest”:[
{
“id”: “f1256812-ad68-4d60-3e5ec-1f9e-edb”,
“serviceActionRequestStatus”: [
{
“id”: “bd3074d0-45db-85ae-f46ae84d2880”,
“operation”: “add”,
“status”: “failure”,
“message”: “Request failed with status code 500”
}
]
}
],
“serviceState”: “Suspend”
}
}
I wanted to add a new Object {“id”: “bd30-74d0-35bc-85ae-f46ae84d-2880”,“operation”: “add”,“status”: “failure”,“message”: “Policy Failed:Request failed with status code 500”} on the “serviceActionRequestStatus” array which is nested under “serviceActionRequest” array.
What query I have to write to achieve this requirement, please help me here?
I am new in couchbase and I tried to write some query which helps me to add object on “serviceActionRequest” object but not in “serviceActionRequestStatus”.
Below is the query:-
UPDATE admin
._default
.server
AS service
SET service.serviceActionRequest = ARRAY_DISTINCT(ARRAY_APPEND(service.serviceActionRequest, {“language”: “en”,“locale”: “CA”,“primary”: “false”})) WHERE service.id=‘15667:0’;
Required Answer like this :
{
“service”: {
“id”: “15667:0”,
“serviceActionRequest”:[
{
“id”: “f1256812-ad68-4d60-3e5ec-1f9e-edb”,
“serviceActionRequestStatus”: [
{
“id”: “bd3074d0-45db-85ae-f46ae84d2880”,
“operation”: “add”,
“status”: “failure”,
“message”: “Request failed with status code 500”
},
{
“id”: “bd30-74d0-35bc-85ae-f46ae84d-2880”,
“operation”: “add”,
“status”: “failure”,
“message”: “Policy Failed:Request failed with status code 500”
}
]
}
],
"serviceState": "Suspend"
}
}
Please help me to give your valuable answers.
Thank You.