Lab - $match: "SyntaxError: missing ; before statement :"

I have my pipeline variable set such that running “db.movies.aggregate(pipeline).itcount()” returns 23 as expected. When I try to run the next command of “load(‘validateLab1.js’)” I get the error in the subject. I connected to the mongo cluster from the directory the js file is stored in so it shouldn’t be an address access issue

Just to add details: I’m using mongo shell version: 3.2.22 and the exact message is

2019-08-23T14:52:35.096-0400 E QUERY [thread1] SyntaxError: missing ; before statement :
@(shell):1:1

2019-08-23T14:52:35.096-0400 E QUERY [thread1] Error: error loading js file: validateLab1.js :
@(shell):1:1

Hey @alex_aberman
Probable I stupid question… but
Are you including those double quotes? Because you should not be

This might help:

If all else fails, supply the full path and escape the backslashes:
load("C:\\Users\\... etc)

good question, no that was just to surround the code I’m actually entering

Just tried that and it thorws the same error. Specifically:

load(‘C:\Users\alex.aberman\Documents\Current_Work\MONGO_CLASS\chapter1\validateLab1.js’)

Just an update: seems to be some parsing issue in the javascript file. If I edit it to comment everything but the empty job call

var validateLab1 = pipeline => {}

Then it returns true, but if I uncomment any component, even just adding a “let x = 1;” then it returns the same failure

So I found a fix but it still doesn’t fully explain it: changing every use of “let” to var fixes it

1 Like

Can I ask what version of Mongo you are using? Since the mongo shell was upgrade in V3.2 to use the new ES6 syntax

So I am slightly confused as to why your fixed has worked.