User Report: get comments

I’m using similar code from the basic joins video, but trying to do it to add comments to a users profile… but it only returns one user with their comments added… can someone tell me why that is?

{
‘from’: ‘comments’,
‘let’: {‘name’: ‘$name’},
‘pipeline’: [
{’$match’:
{’$expr’:{’$eq’:[’$name’, ‘$$name’]}
}}],
‘as’: ‘comments’
}

The collection users has a unique index on the field email. This indicates to me that you should $match on the field email rather than the field name.

It is not clear what you mean by

Having French as my mother tongue, I can interpret the above in 2 ways:

  1. Does it return many users and only one of them has comments?
  2. Does it return only one user with its comments?

If you mean the second point, then the issue lies in the code/stages before or after the one you show. If the it the first, then I do not know yet.

1 Like

Thank you… changing the field from name to email did work.