Get all major versions based on limit


#1

{
“type”: “versionn”,
“versions”: [
{
“major”: “1.0”,
“minor”: [
“1.0.1”,
“1.0.2”
]
},
{
“major”: “1.1”,
“minor”: [
“1.1.1”,
“1.1.2”
]
},
{
“major”: “1.2”,
“minor”: []
}
]
}

how to get only majors from above. output as below

[“1.0”,“1.1”,“1.2”]

and how to get max minor version from above doc. output as
[“1.1.2”]


#2
SELECT d.versions[*].major , ARRAY_MAX( ARRAY_FLATTEN(d.versions[*].minor,2) ) minormax
    FROM default AS d
    WHERE d.type = "version";

Also checkout N1QL documentation and tutorials

https://docs.couchbase.com/server/5.5/n1ql/n1ql-language-reference/index.html
https://query-tutorial.couchbase.com/tutorial/#1