MongoDB Update & Aggregate Problem: Skipping over aggregation

I have two tables, one for messages to be logged and one that is for each member of the group. When a message is upvoted, I want to add an entry for the message and push each reaction on that message to an array.

Every time a reaction is added I want to update the member table to reflect the sum of all of the reaction.value fields.

This is the code I have written to do so. When this runs from a sandbox I made in VisualStudio using a MongoDB add on it runs fine, however when ran using my app, only the message document is added and without any error it appears to skip the aggregation to the member document.

Here is the code I am using to insert the documents to the database and to aggregate once the document is inserted:

await mongodb.collection("Messages").updateOne({ _id:},
            $push: { 
                reactions: { 
                reauth: reAuth, 
                removed: false, 
                value: actualKarmaDB,
            }, {safe: true, "upsert": true})
    await mongodb.collection("Messages").aggregate([
            $match: { 
        $project: {
            _id: "$authorid",
            username: "$author",
            messageKarma: {$sum: "$reactions.value"},

    {   $merge: { 
            into: "Members", 
            on: "_id", 
            whenMatched: "replace", 
            whenNotMatched: "insert" 

Also here is a look at what the insertion into “Messages” looks like: Inserted Data


In this case the answer was due to mongoose not supporting merge for aggregation. Had to use $out.

Additionally this is a known issue with Mongoose Node.js, see here: Mongodb node.js $out with aggregation only working if calling toArray()