Chapter 1 homework lab: Pipeline returns 23 but validation fails

Hi - my pipeline returns 23 documents but validateLab1.js fails and gives me an error message. Any idea on what I’m missing

See outputs below:

MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.movies.aggregate(pipeline)

{ "total" : 23 }

MongoDB Enterprise Cluster0-shard-0:PRIMARY>validateLab1(pipeline)

You aren't returning the correct number of documents

MongoDB Enterprise Cluster0-shard-0:PRIMARY>

Thanks,

Sandeep

Based on the quiz I am supposed to get back a number. I opened the js file and I suppose I could solve for the formula but would like to know what I am doing wrong. Am I not supposed to put a count stage in my pipeline?

Yep that was it. I had put a $count in my pipeline to test the numbers. Confession: Used Compass to build the pipeline so I could keep the bother of the syntax of curly braces and box brackets to a minimum BUT had put the count in there to get test the pipeline. Oh well so there you go…

@ Sandeep_48470

Glad you solved it. Yes, you need to generate just the number. You can use itcount() to verify, but not $count. Good luck.

@Sandeep_48470 I was having the same result… my recomendation is: check the name of the field “genres” that you are using in your pipeline