What field does the value belong to “labors of love”?

One question, What field does the value belong to “labors of love”?

Hi @ANGELA_CABALLERO_ARROYO,
As mentioned in the problem statement:

Let’s find how many movies in our movies collection are a “labor of love”, where the same person appears in cast, directors, and writers
Hint: You will need to use $setIntersection operator in the aggregation pipeline to find out the result.

If you have any doubts, please feel free to reach out to us.

Thanks and Regards.
Sourabh Bagrecha,
MongoDB

One doubt ,when I tried to use this comand I got that:

 db.movies.aggregate([{$project:{"_id":0,"writers":1,"directors":1,"cast":1,"coinciden":{$setIntersection:["$writers","$directors","$cast"]}}},{$count:"labors of love"}])

Here is the result:

{ "labors of love" : 44488 }

looks like it is all the documents in the collections.

I think you want to eliminate from the result set all documents where the intersection is empty because a movie is considered a labor of love when the same person is in the 3 arrays.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.