GraphQL
db.groups.aggregate([
// {$match: {"_id": ObjectId("613a0053620e4a5a3f041de0")}},
{$match:{$and:[{_id:{$in:[ObjectId("613a0053620e4a5a3f041de0"),ObjectId("613a1fb0e7f699352ad114cf")]}},{deleted:false},{parent:{$nin:[ObjectId("613a0053620e4a5a3f041de0"),ObjectId("613a1fb0e7f699352ad114cf")]}}]}},
{$graphLookup:{from:"groups",startWith:"$_id",connectFromField:"_id",as:"children",connectToField:"parent"}},
// {$lookup:{from:"usergroups",localField:"_id",foreignField:"groupId",as:"userGroup"}},
]);
db.groups.aggregate([
{$match:{_id:ObjectId("613a1fb0e7f699352ad114cf")}},
{$graphLookup:{from:"groups",startWith:"$_id",connectFromField:"_id",as:"children",connectToField:"parent"}},
{$graphLookup:{from:"groups",startWith:"$_id",connectFromField:"parent",as:"hierarchy",connectToField:"_id"}},
{$lookup:{from:"evalstages",localField:"hierarchy._id",foreignField:"group",as:"evalStages"}},
]);
db.groups.aggregate([
{$match:{_id:ObjectId("613a1fb0e7f699352ad114cf")}},
{$graphLookup:{from:"groups",startWith:"$_id",connectFromField:"parent",connectToField:"_id",as:"hierarchy"}},
{$lookup:{from:"usergroups",localField:"hierarchy._id",foreignField:"groupId",as:"userGroups"}},
{$lookup:{from:"schoolusers",localField:"userGroups.userId",foreignField:"_id",as:"users"}},
{$unwind:"$userGroups"},
{$match:{"userGroups.userId":ObjectId("614c185bb8e8446d027cb2ab")}},
{$replaceRoot:{newRoot:"$userGroups"}}
]);
db.groups.aggregate([
{$match:{_id:ObjectId("613aa38f7183897ace14a097")}},
{$graphLookup:{from:"groups",startWith:"$_id",connectFromField:"parent",as:"hierarchy",connectToField:"_id"}},
{$lookup:{from:"usergroups",localField:"hierarchy._id",foreignField:"groupId",as:"groups"}},
{$match:{"groups.userId":ObjectId("613ffcdd6ecf6f293d7d5072")}},
{$project:{
"groups.roleType":1,
"groups.userId":1
}}
]);
db.getCollection('messages').find({"authorId": { $all: ["614c39a5db1a041ec0ae4624"] }})
db.messages.aggregate([
{$lookup:{from:"schoolusers",localField:"authorId",foreignField:"_id",as:"authors"}},
{$unwind: "$authors"},
{$project: { "_id": 1, "commentId": 1, "authorId": 1, "authorType": 1, "text":1, "attachments":1, "authorName": "$authors.name" } }
]);