Lab - $match - validateLab1(pipeline) command running forever

I have 2 issues
First, for

  • imdb.rating is at least 7
  • genres does not contain “Crime” or “Horror”
  • rated is either “PG” or “G”
  • languages contains “English” and “Japanese”
    I got 18 records after running db.movies.aggregate(pipeline).itcount()

Second, I am on windows 10 and run
MongoDB Enterprise mflix-shard-0:PRIMARY> load(‘D:\MongoDB\Queries\validateLab1.js’)
returned true
I assume script was loaded but when run
MongoDB Enterprise mflix-shard-0:PRIMARY> validateLab1(pipeline)
it does not complete and freeze forever so I need to kill it

Can you explain why? What did I do wrong?

Hey @Jacob_32894

Straight from the lab

As a hint, your aggregation should return 23 documents. You can verify this by typing db.movies.aggregate(pipeline).itcount()

So perhaps your pipeline is incorrect.


I would agree that I believe it has loaded.

If you are still having issues after looking at your pipeline, and you believe it to be right, then feel free to get back to me. You can put print() statements inside the validateLab1.js file if all else fails…

1 Like

Hi @Jacob_32894,

In addition to @natac13’s reply, make sure that you are connected to the correct cluster. Please use the following connection string:

mongo “mongodb://,,” --authenticationDatabase admin --ssl -u m121 -p aggregations --norc

After connecting to the m121 course Atlas cluster using the above connection string, create the pipeline using the $match stage.

Please let me know, if you have any questions.


1 Like

Attention Sean Campbell

Hi Sean

Thanks for quick response

Below is my condition

var pipeline = [{ $match: }]

Can you advise what part is wrong?

I will try to put print into .js




So that pipeline is looking good, and on that note please remove it so no one else gets the answer.

However it is given you 18 instead of 23? Let me try it out and ill get back to you.


Ok So I have use the connection command provide by @Sonali_Mamgain And got connected fine.

mongo "mongodb://,," --authenticationDatabase admin --ssl -u m121 -p aggregations --norc

Then I assigned your exact pipeline(minus changing the fancy quotes to normal) to a variable and ran

var pipeline = [... what you should delete from the post since it is the answer]

Got 23!

So try with the above connection command and load your pipeline again and use it against the movies collection in the aggregations db

You can check what database you are using in the mongo shell by running


Thanks, I removed my pipeline
I will verify connection string


1 Like

Hi Sean, Sonali_48808, Natac13
The major issue was there are 2 collections movies - one in mflix and another in aggregations - I was in mflix (wrong one)
Thanks for your help!

1 Like