Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var GroupCollection = User.getDataSource().connector.collection(User.app.models.group.modelName);
- GroupCollection.aggregate([
- {$match: {status: true}},
- {$sort: {updatedAt: 1}},
- {
- $lookup: {localField: "_id", from: "member", foreignField: "groupId", as: "members"}
- },
- {
- $group: {
- _id: "$_id",
- members: {$addToSet: "$members.userId"}
- }
- },
- {
- $project: {
- _id: 1,
- title: 1,
- members: {$arrayElemAt: ["$members", 0]}
- }
- },
- {
- $match: {
- $and: [
- {members: {$all: paticipants}},
- {members: {$size: paticipants.length}}
- ]
- }
- }
- ], function (err, result) {
- console.log("Found result", paticipants, result);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement