Hi, I have a question regarding the use of ARRAY_STAR, given something similar to this stored in my couchbase:
{
"id": 1.
"other_attr" : "some_value",
"compoundKey": {
"key_1": "a",
"key_2": "b",
"key_3": "c"
}
},
{
"id": 2,
"other_attr" : "some_value",
"compoundKey": {
"key_2": "c",
"key_3": "d",
"key_4": "e"
}
}
]
How can I achieve something like this?
{
compoundKey: {
"key_1": ["a"],
"key_2": ["b", "c"],
"key_3": ["c", "d"],
"key_4": ["e"]
}
}
I found the documentation on ARRAY_STAR and tried to utilize it in the following query, but it doesnt seem to be working:
SELECT ARRAY_STAR(compoundKey) from dataset → this returns an array of null objects
The ARRAY_STAR function appears to work when assigning the document list as a variable, e.g.
LET ARR = [
{
"compoundKey": {
"key_1": "a",
"key_2": "b",
"key_3": "c"
}
},
{
"compoundKey": {
"key_2": "c",
"key_3": "d",
"key_4": "e"
}
}
]
SELECT ARRAY_STAR(ARR)
May I know if there is a way to write a query that extracts out the array of compoundKey objects and apply ARRAY_STAR to the result?