I found this answer on StackOverflow, but I don't understand the last part of the answer.https://stackoverflow.com/questions/50363220/modelling-for-friends-schema-in-mongooseUser.aggregate([ { "$lookup": { "from": Friend.collection.name, "let": { "friends": "$friends" }, "pipeline": [ { "$match": { "recipient": ObjectId("5afaab572c4ec049aeb0bcba"), "$expr": { "$in": [ "$_id", "$$friends" ] } }}, { "$project": { "status": 1 } } ], "as": "friends" }}, { "$addFields": { "friendsStatus": { "$ifNull": [ { "$min": "$friends.status" }, 0 ] } }} ]) What does aggregate even do? I took a tutorial course and this aggregate function wasn't covered.
Submitted October 20, 2019 at 12:02AM by jesusscript
No comments:
Post a Comment