Graphlookup: add data to "as" and order by actual distance

Hi all. This is my first post. Please be gentle. :smile:

I have 2 questions.

I’m trying to use Mongo for a small graphDB via $graphlookup.
I’ve successfully used the graphlookup airline tutorial to create the first query to show the equivalent with my data. Using MongoDB As Graph Database: Use Cases | MongoDB

My nodes collection is simple: the ID, type of node, and a description…

The edges(routes) collection is simply the to/from IDs of each of those nodes.

So I can see routes between nodes. Easy and straight forward so far.

Question 1- In any simple GraphLookup query, how can I include the node data for each route it references into the “as” return…

Example:

db.nodes.aggregate(
[
  {
    $match: {
          gid: "6fe07aa5-fec0-4eca-a456-f29bff451b04",
    }
  },
  {
    $graphLookup: {
        from: 'edges',
        startWith: '$gid',
        connectFromField: 'from',
        connectToField: 'to',
        as: 'connections',
        depthField: "depthField",
        maxDepth: 5
    }
 }
])

I’d want whatever is returned with the as: “connections” to also include the data from that gid’s db.nodes …

Question 2- But in my edges(routes) collection, I also have distance integer for that route. I’d want to order by the sum of the shortest distance, then depth. How would I do that? Any simple example would be greatly appreciated.

So it would look more like this:

{
   _id:"whatever",
   airline: {
     id: 4089, 
     name: 'Qantas', 
     alias: 'QF', 
     iata: 'QFA' 
   },
   src_airport: 'AKL',
   dst_airport: 'BNE',
   airplane: '73H 388'
  **distance: 100**
 }

So I’d want to order by that distance, then the depth…

Thank you! I chose to post here first because I feel like anytime I ask on stack, I just get told my question is stupid. hah.