Simple N1QL on array

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

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

1 Like

Thanks you very much @johan_larson, its working…