Chapter 1: Basic Aggregation - $match and $project error

Hi, I have this error:

MongoDB Enterprise Cluster0-shard-0:PRIMARY> load('validateLab1.js')
true
MongoDB Enterprise Cluster0-shard-0:PRIMARY> db.movies.aggregate(pipeline).itcount()
23
MongoDB Enterprise Cluster0-shard-0:PRIMARY> validateLab1(pipeline)
2019-06-23T02:53:08.425+0200 E QUERY    [js] ReferenceError: validateLab1 is not defined :
@(shell):1:1
MongoDB Enterprise Cluster0-shard-0:PRIMARY>

I have no idea why this happens.

@rodro

Honestly, neither do I. If I run your exact same sequence, getting the correct itcound() result, then the whole sequence works correctly. Try reloading ‘validateLab1.js’ and see what happens. Good luck.