2

I have following collections with fields in my mongodb database:

Category
    cat_id: cat_id_1, cat_name: education
    cat_id: cat_id_2, cat_name: Sports

Keywords
    key_id: key_id_1, key_name: social
    key_id: key_id_2, key_name: places

Artists
    art_id: art_id_1, artist_name: Brian Adams
    art_id: art_id_2, artist_name: ACDC


Episodes
    ep_id: ep_id_1, ep_title: "Episode Title 1", categories: [cat_id_1, cat_id_2],keywords: [key_id_1], program_id: pr_id_1, artists: [art_id_1, art_id_2]

Programs
    pr_id: pr_id_1, pr_title: "Program Title 1", categories: [cat_id_1, cat_id_2],keywords: [key_id_1], program_id: pr_id_1, artists: [art_id_1, art_id_2]

Now I need to write a query which will list programs based on search string matching Category, Artist, keywords, Episodes Title or Program Title. It would have been easy if it's a single collection by just using find and $regex and supplying searched string to it. However I failed to apply the same for this condition.

New contributor
TheLittleNaruto is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

TheLittleNaruto is a new contributor. Be nice, and check out our Code of Conduct.

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

Browse other questions tagged or ask your own question.