Join in MongoDB in movies and comment collection

hallo,

i just take a look at this example:
Join

now i want to try in my movies and comment collection:

but i got empty array.

what is wrong ?

thanks in advance

1 Like

@Stev_80585 as per your other thread, you need to edit your post and link it to the right course. Otherwise you’re not going to get relevant advice.

oke…like this

That’s it :slightly_smiling_face: :+1:

1 Like

Hi @Stev_80585,

It might be because there are no documents in comments collection for that movie. If this if just for your learning, you can add a pipeline stage which will check on $size of comments array further and that will give you documents containing those movies which have comments as well.

Kanika

thanx…yes just for learning purpose…

how can i count the array ?

Here’s the documentation for $size. You can add another $match stage to filter down to documents with an array size greater than 0.

1 Like

how ?

If you notice, I mentioned using a $match stage not $addFields. The $size documentation I posted is for the query operator syntax that works with $match. However, there’s a $size projection syntax too which will work with $addFields but it will not filter down.

1 Like

still err

It’s an unknown error so something unusual has gone wrong. You can try to initially turn on and off the green auto preview button. If that doesn’t work then take a copy of your queries and try to refresh the connection (top left hand corner of Compass).

1 Like

thanks…you right