I have 3 collections with data in following way
Collection Names
i) Customer
ii) Orders
iii) Wishlist
iv) Documents
Can someone please help in N1QL queries for following outputs mentioned below?
Customer Document:
Key : 101
Document :
{
“name”: “john”,
“email” : “john@email.com”,
“id” : “101”,
“orders” :[
“101_order_1”,
“101_order_2”
],
“wishlist” : [
“101_wishlist_1”,
“101_wishlist_2”,
"101_wishlist_3
],
“documents” : “101_documents_1”
}
Orders Documents:
Key: 101_order_1
Document:
{
“numOfProducts” : 5,
“billAmount” : 2500,
“paymentType” : “COD”,
“address” : “temple street”
}
Key: 101_order_2
Document:
{
“numOfProducts” : 10,
“billAmount” : 7000,
“paymentType” : “Debit Card”,
“address” : “Park Street”
}
Wishlist Documents:
Key: 101_wishlist_1
Document :
{
“name” : “Jeans”,
“noOfProducts” : 10,
“size” : 32,
“colour” : “blue”
}
Key: 101_wishlist_2
Document :
{
“name” : “Shirts”,
“noOfProducts” : 5,
“size” : 40,
“colour” : “black”
}
Key: 101_wishlist_3
Document :
{
“name” : “Jackets”,
“noOfProducts” : 3,
“size” : 44,
“colour” : “brown”
}
Customer Documents:
Key: 101_documents_1
Value:
{
“aadhar” : “/Aadharcard”,
“pan” : “/pancard”,
“aadharNumber” : 1234
}
I want to execute two queries. In each query, the nested document should be embedded in answer and duplication should not be there. I need output in following way. Please help in writing the required N1QL queries.
i) Query Needed for following Output
{
  "name": "john",
  "email" : "john@email.com",
  "orders" :[
      {
        "numOfProducts" : 10,
        "billAmount" : 7000,
        "paymentType" : "Debit Card",
        "address" : "Park Street"
      },
      {
        "numOfProducts" : 5,
        "billAmount" : 2500,
        "paymentType" : "COD",
        "address" : "temple street"
      }
    ],
  "wishlist" : [
     {
      "name" : "Jeans",
      "noOfProducts" : 10,
      "size" : 32,
      "colour" : "blue"
    },
    {
      "name" : "Shirts",
      "noOfProducts" : 5,
      "size" : 40,
      "colour" : "black"
    },
    {
      "name" : "Jackets",
      "noOfProducts" : 3,
      "size" : 44,
      "colour" : "brown"
    }]
}
ii) Query Needed for following Output
{
  "name": "john",
  "email" : "john@email.com",
  
  "orders" :[
      {
        "numOfProducts" : 10,
        "billAmount" : 7000,
        "paymentType" : "Debit Card",
        "address" : "Park Street"
      },
      {
        "numOfProducts" : 5,
        "billAmount" : 2500,
        "paymentType" : "COD",
        "address" : "temple street"
      }
    ],
    
  "wishlist" : [
     {
      "name" : "Jeans",
      "noOfProducts" : 10,
      "size" : 32,
      "colour" : "blue"
    },
    {
      "name" : "Shirts",
      "noOfProducts" : 5,
      "size" : 40,
      "colour" : "black"
    },
    {
      "name" : "Jackets",
      "noOfProducts" : 3,
      "size" : 44,
      "colour" : "brown"
    }],
    
  "documents" : {
      "aadhar" : "/Aadharcard",
      "pan" : "/pancard",
      "aadharNumber" : 1234
    }
}
Can someone please help in N1QL queries for following outputs mentioned below?