Simple N1QL on array


#1

Hi,

Below is the document,

{
“users”: [
{
“userId”: “1”,
“username”: “admin”,
“password”: “111”,
“userType”: “admin”
},
{
“userId”: “2”,
“username”: “x”,
“password”: “222”,
“userType”: “user”
},
{
“userId”: “3”,
“username”: “y”,
“password”: “333”,
“userType”: “user”
}
]
}

Need N1QL to generate this output

[
{
“userId”: “1”,
“username”: “admin”,
“password”: “111”,
“userType”: “admin”
},
{
“userId”: “2”,
“username”: “x”,
“password”: “222”,
“userType”: “user”
},
{
“userId”: “3”,
“username”: “y”,
“password”: “333”,
“userType”: “user”
}
]

Kindly required ASAP.

Thanks


#2

If you have the above as a single document in bucket “temp” (its ID doesn’t matter), you can get the desired result using this query:

select raw users from temp unnest users


#3

Thanks you very much @johan_larson, its working…