User Reports: Read Concern

I am struggling to get anything returned for the User Reports exercise… the aggregation I am using works to return the correct results through compass, but I plug it into my code and get “undefined”… find my code below, if any can help that’d be awesome

const pipeline =
[
{
‘$sortByCount’: ‘$email’
}, {
‘$limit’: 20
}
]

Your undefined comes from code before or after that assignment.

Hi Steevej - Thanks for getting back again… this is the full code below… when I run ‘npm test -t user-report’ in Git, I get :

Expected: 20
Received: undefined

try {

  const pipeline =

  [

    {

      '$sortByCount': '$email'

    }, {

      '$limit': 20

    }

  ]


  
 const aggregateResult = await comments.aggregate(pipeline)

  return await aggregateResult.toArray()

}

How to you define comments?

Please provide a screenshot when you get the error.

Hi Brett,

did the M220JS some weeks ago by the end of last year. So I looked into my solution archive. You know the Compass automatically uses the majority readConcern, so data are never stale with Compass. Maybe it’s worth trying readConcern = { level: majority } right off the bat in your exercise?

Hope, you’ll find a path forward soon, - Regards. M.

Thanks for the responses. I was able to find a janky way to pass the test.
Instead of:

  • const aggregateResult = await comments.aggregate(pipeline)*
    I used:
  • var aggregateResult = await comments.aggregate(pipeline)*

Still a little confused by why using const wouldn’t work though…