Hi
I have 2 types of documents in the database
[{
"admins": [
"2dd72827f7e948cc9257cd9fa6dc3f7a"
],
"companyName": "ABC - company",
"developers": [
"2dd72827f7e948cc9257cd9fa6dc3f7a"
],
"uuid": "0001bb842f974fb6947b744be48b2a68",
"type" : "company"
},
{
"admins": [
"d2054b62bb614db3bed6d26ad71b14b8",
"c6eb89e4242d4bf2a746d1afcd869c64",
"846fc06363d64c55b318256cb53c3f58"
],
"companyName": "CDE company",
"developers": [
"2feb377cfc504bd0870aba3027bc4893",
"d2054b62bb614db3bed6d26ad71b14b8",
"c6eb89e4242d4bf2a746d1afcd869c64",
"846fc06363d64c55b318256cb53c3f58"
],
"uuid": "0007bd40b4bb4651a4381aad31cd7bb6",
"type" : "company"
}
]
And 2nd type of document is
[
{
"uuid" : "2dd72827f7e948cc9257cd9fa6dc3f7a",
"name" : "someUser"
"email" :abc@xyz.com"
"type" : "user"
}
]
I Want to create a table or a json array with the following details
[
{ userName ,
companyName,
email
}
]
If user is in multiple companies I want multiple records
[
{ userName : “abc” ,
companyName : “xyz”,
email :"abc@xyz.com
} ,
{ userName : “abc” ,
companyName : “lmn”,
email :"abc@lmn.com
}
]
The bucket name is api_external and all documents are in the bucket.
Can you tell me how i can write this N1QL . We have an index on the document type