Is it possible to use a $group - aggregration when adding a field with $addFields to a document?
/* 1 */
{
"_id" : "1",
"version" : 0,
"data" : "aaaa"
}
/* 2 */
{
"_id" : "2",
"version" : 0,
"data" : "aaaa"
}
/* 3 */
{
"_id" : "3",
"version" : 1,
"data" : "aaaa"
}
The aggregation is something similiar to this.
db.getCollection("TestCollection").aggregate([{
$addFields: {
"test": {
$group: {
_id: null,
}
}
}
}])