I have a buket with a single a document like below .
{
"productStatus" :{
"productID":"Status",
"productID1":"Status1",
"productID2":"Status2"
}
}
The product ID is a foreign key for product records .
I am using the below query to get productName and ID
SELECT api_external.data.displayName AS productName
,uuid AS productId
FROM api_external USE KEYS(ARRAY "product::" || v FOR v IN OBJECT_NAMES(t1.productStatus) END)
from bucket as t1
I want to get status as well as part of the SQL like
SELECT api_external.data.displayName AS productName
,uuid AS productId,
t1.productStatus[uuid] as status
FROM api_external USE KEYS(ARRAY "product::" || v FOR v IN OBJECT_NAMES(t1.productStatus) END)
from bucket as t1
result must look like
{
"products": [
{
"productId": "ID",
"productName": "Name",
"status": "status"
},
{
"productId": "ID1",
"productName": "Name1",
"status": "status1"
}
]
}
How do i do it ?