That helped a lot and dispite the fact that this isn’t beautiful, this is what I came up with:
(function() {
print("DBC")
var d = new Date();
print(d.getDate() + "." + (d.getMonth()+1) + "." + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes())
print(db.schools.countDocuments())
print(db.accounts.countDocuments())
print(db.getCollection("accounts").aggregate([ ... ]))
......
......
})()
So the code gets wrapped up in this function expression and all aggregates get wrapped up in prints (otherwise it wouldn’t print like it would normally do) and there you go, no empty lines:
DBC
3.3.2023 14:54
1911
1265809
[ { userId: 11924 } ]
...