For example, i have 2 collections:
First one is named as "Songs" and documents in this collection store all metadata about song like title
, duration
, release_date
and other. Beside this, there are also artist
and producer
fields, these fields stores ids of relational documents from "Stars" collection.
Example of document in "Songs" collection:
{
id: SONG_ID
title: TITLE,
duration: DURATION,
release_date: ISO_DATE,
...
artist: STAR_ID
producer: STAR_ID
}
Second one as you guess is "Stars" collection and documents in this collection store information about stars like fullname
, date_of_birth
and other.
Example of document in "Stars" collection:
{
id: STAR_ID
fullname: FULLNAME,
date_of_birth: DATE_OF_BIRTH
...
}
Suppose i want to find songs that (1 condition) have "love" word in their titles, (2 condition) released in 2017 year and (3 condition) from artists like Rihanna or Zara Larsson. Please note that my problem is different from simple left outer join. Note that in this query 3rd condition relates to information that stored in second collection "Stars", so i dont want just pollute artist and producer fields with information from "Stars" collection but also i want to choose songs with stars just like Rihanna or Zara Larsson.
What is the best and fastest way to do this?
Thanks for your help!