Add an array inside the document after checking whether it exists

I have the below output from my aggregate query
{_id:“053f1c9a-761e-4925-8188-3e6e9214824a”
Code:“00005”
Name:“Tests2”
Details:Array
Notification:Array
Books:Array
},
{_id:“053f1c3a-761e-4925-8188-3e6e9214824a”
Code:“00006”
Name:“Tests”
Details:Array
Books:Array
}

If you see the second document the Notification array is missing. I want to add the missing array after checking if it exists or not. Any Ideas?

For things like that, I usually prefer to do it on the data access layer of the application. But to do it on the aggregation you could probably do it with something like the following untested addFields stage:

{
  "$addFields :
  {
    "Notification" : { "$ifNull" : [ "$Notification" , [] ] }
  }
}