Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have make a union of two collections without any conditions, and need to project all fields in both tables in one query. But with my query I am able to see the output of customer_id, name and concatination. The collection data which I am trying to project inside the union query is not showing.

I am not able to figure out the problem. Can anyone please help me on this?

What I have tried:

db.customer.aggregate(
        {
          "$unionWith": {
            "coll": "parent_child", "pipeline": [
              {
                "$project": {
                  "child_id":"$CUSTOMER_CHILD_ID",
                  "parent_id":"$CUSTOMER_PARENT_ID"
              }
            }
            ]
          }
        },
        {
          "$project":{
            "customer_id":"$CUSTOMER_ID",
            "name":"$NAME",
            "concatination":{"$concat":["$CLASS","$COMPANY_CODE"]}
          }
        }
      )
Posted
Updated 2-Jun-22 10:53am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900