Intersect the output of two query pipelines

Hello,
I’m trying to create a MongoDB pipeline that does the same as this SQL query:

SELECT DISTINCT A.ID FROM
  (Query_A) A 
  INNER JOIN 
  (Query_B) B
  ON A.ID = B.ID

I’ve come up with the following code to run both query pipelines:

[
    {
        "$facet": {
            "query_a": [...],
            "query_b": [...]
        }
    },
   ...
]

These pipelines return IDs and I want to get an intersection of these IDs ("$query_aID" equal to “$query_b.ID”). I’m still struggling to come up with a solution for this seemingly easy problem.