0

I am a beginner to Mongo. I want to simulate an inner join using the aggregate $lookup and I have 3 collections ( 1 in a separate database ) I want to see all the projects that a user is part of can someone give me an example?

Here are the 3 collections

"projects.details"

    {
        "_id" : ObjectId("5684f3c454b1fd6926c324fd"),
        "projName" : "I am a test project",
        "active" : "true"
        "projId" : "project1"
    }

"userDetails.projMembership"

{
    "_id" : ObjectId("56d82612b63f1c31cf906003"),
    "projId" : "project1",
    "userId" : "user1",
    "status" : "Invite"
}

"userDetails.details"

{
    "_id" : ObjectId("56d82612b63f1c31cf906003"),
    "userId" : "user1",
    "email" : "user1@somemail.com"
}

1 Answer 1

0

After searching far and wide for an answer, The answer is simple This is NOT possible in Mongo. The only way to achieve the result I was looking for is to perform a $lookup for the 2 collections in the userDetails DB, store the results in an array, then perform another lookup against the collection in the projects DB. Hope this helps someone out there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.