perak / meteor-joins

Collection joins for Meteor
77 stars 7 forks source link

For a simple join, how do you use an array as the foreign key ? #8

Open tried2call opened 8 years ago

tried2call commented 8 years ago

Based on your example of a simple join between two collections: My foreign key is an array of several values (actually several Mongo _id fields). How can I use this multi-value array and link to multiple documents in the 'linked-to' file ?

It seems that I would need to loop-thru this array somehow to make these linkages.

Thanks !

perak commented 8 years ago

@tried2call sorry, package cannot do that automatically.

raza2022 commented 5 years ago

@perak I have the same case, let's assume my company collection looks like below

{
    _id : "dYo4tqpZms9j8aG4C"
    owner : "yjzakAgYWejmJcuHz"
    name : "Labbaik Waters"
    peoples : ["yjzakAgYWejmJcuHz", "yjzakAgYWejmJcuHz"],
    createdAt: "2019-09-18T15:33:29.952+00:00"
}

here you can see peoples field contains the user ID's so How I publish this userId's as user Documents, it package support it? @tried2call have you solved your issue, any workaround