Join between String and ObjectId

0

How to do a join between two collections, using objectid in one and string in another?

Sample document event :

{
    _id: ObjectId(5b188aa5f9bf7c4c7d3cf637)
    name: "aniversario"
    date: "2019-09-21T03:00:00.000Z"
    teachingInstitute: "5b15190626db0b1ad576f259" //string
    description: "balblalbalablbala"
    user:"5b187941ced0c63bba2285bd"
}

Sample document teachingInstitute :

{
    _id: 5b15190626db0b1ad576f254
    domain: "www.ipametodista.edu.br"
    name: "CESUPA - FACULDADE DE DIREITO DE PORTO ALEGRE"
    phone: "3316-1102"
    place: "RUA JOAQUIM PEDRO SALGADO, 80 RIO BRANCO"
}

I tried, unsuccessfully:

event.aggregate({
    $lookup: {
        from: 'teachingInstitute',
        localField: 'teachingInstitute',
        foreignField: '_id',
        as: 'a'
    }
});

I believe the problem is the data type, in a string and in the other objectid

    
asked by anonymous 07.06.2018 / 05:39

0 answers