$ lookup和$ match Mongodb golang

I want to get document with foreign key by using $lookup and $match on MongoDB.

There is a "Jobs" collection which stores Job document. In Job document there are two field using as foreing key "creatorParent" and "Children". CreatorParent is a foreign key for "Users" collection and Children array contains id for user's children.

When I list the whole jobs, I want to retrieve detail from "Users" collection for both CreatorParent ID and ChildrenID. I want to marshall "Job" document with ParentDetail and ChildDetail. I don't want to write a custom method for that. Is it possible to handle it with MongoDB query?

By the way I'm beginner on MongoDB so should store needed details on Children and CreatorParent instead of storing ObjectId?

Jobs Collection

Users Collection

Users document:

{
    "_id" : ObjectId("58daf84877733645eaa9b44f"),
    "email" : "meto93@gmail.com",
    "password" : "vpGl+Fjnef616cRgNbCkwaFDpSI=",
    "passwordsalt" : "99397F4A9D3A499D96694547667E74595CE994D2E83345D6953EF866303E8B65",
    "children" : [ 
        {
            "_id" : ObjectId("58daf84977733645eaa9b450"),
            "name" : "Mert",
            "age" : 5,
            "additionalinformation" : "ilk cocuk",
            "creationtime" : ISODate("2017-03-28T23:56:56.952Z"),
            "userid" : ObjectId("58daf84877733645eaa9b44f"),
            "gender" : null
        }, 
        {
            "_id" : ObjectId("58daf84977733645eaa9b451"),
            "name" : "Sencer",
            "age" : 7,
            "additionalinformation" : "ikinci cocuk",
            "creationtime" : ISODate("2017-03-28T23:56:56.952Z"),
            "userid" : ObjectId("58daf84877733645eaa9b44f"),
            "gender" : null
        }
    ]
}

Job

{
    "_id" : ObjectId("58db0a2d77733645eaa9b453"),
    "creationtime" : ISODate("2017-03-29T01:13:17.509Z"),
    "startingtime" : ISODate("2017-04-03T13:00:00.000Z"),
    "endingtime" : ISODate("2017-04-03T17:00:00.000Z"),
    "children" : [ 
        ObjectId("58daf84977733645eaa9b450"), 
        ObjectId("58daf84977733645eaa9b451")
    ],
    "creatorparent" : ObjectId("58daf84877733645eaa9b44f"),
    "applicants" : []
}

If I understood it correctly. A similar solution is achievable using MongoDB 3.4's $addFields and $lookup aggregation steps.

Mongo aggregation:

[
    {
        $addFields: { 
            "job":"$$ROOT"
        }
    },
    {
        $unwind: {
            path : "$children"
        }
    },
    {
        $lookup: {
            "from" : "users",
            "localField" : "creatorParent",
            "foreignField" : "_id",
            "as" : "creatorParent"
        }
    },
    {
        $lookup: {
            "from" : "users",
            "localField" : "children",
            "foreignField" : "_id",
            "as" : "children"
        }
    },
    {
        $group: {
            "_id": "$_id",
            "job": { "$first": "$job" },
            "creatorParent" : { "$first" : "$creatorParent" },
            "children": { "$addToSet": {  $arrayElemAt: [ "$children", 0 ]  } }
        }
    }
]

The output will look like the following:

{ "_id" : ObjectId("58da9cb6340c630315348114"), 
"job" : {
    "_id" : ObjectId("58da9cb6340c630315348114"), 
    "name" : "Developer", 
    "creatorParent" : ObjectId("58da9c79340c630315348113"), 
    "children" : [
        ObjectId("58da9c6d340c630315348112"), 
        ObjectId("58da9c5f340c630315348111")
    ], 
    "hourly_rate" : 12.0, 
    "additional_information" : "other infos"
}, 
"creatorParent" : [
    {
        "_id" : ObjectId("58da9c79340c630315348113"), 
        "name" : "The Boss", 
        "age" : 40.0
    }
], 
"children" : [
    {
        "_id" : ObjectId("58da9c5f340c630315348111"), 
        "name" : "James", 
        "age" : 28.0
    }, 
    {
        "_id" : ObjectId("58da9c6d340c630315348112"), 
        "name" : "Andrew", 
        "age" : 26.0
    }
]}

UPDATE:

If you substitute the last $group stage with this:

{
    "_id": "$_id",
    "name": { "$first": "$name" },
    "jobstatus": { "$first": "$jobstatus" },
    "hourlyrate": { "$first":"$hourlyrate" },
    "creatorparent" : { "$first" : "$creatorparent" },
    "children": { "$addToSet": {  $arrayElemAt: [ "$children", 0 ]  } }
}

Then you can achieve what you would like to, but in this $group stage you have to specify every field of job one-by-one with the $first expression.