Mongosh Load .js File

I keep seeing that you can only load a javascript file using the mongo shell. However, I was under the impression you could use Compass to complete the lessons, and Compass only has Mongosh as its shell from what I can see. Is there a work around for loading a javascript file on Mongosh, or a way to change the shell on compass from Mongosh?

I don’t believe you can use the ‘load’ command in MongoDB Compass. Although if you are going through the Mongo University courses, it is usually recommended to use the built in IDE to do the work.

There will be other things that you can’t do with Compass (ie starting stopping mongodb processes, creating replica sets, and much more). Compass is really just a tool used to view/query data.

I am confused then, because when I download “enterprise” from the courses, it downloads compass so where would I find the built-in IDE?

What data are you trying to load?
The data required for this course is loaded at the creation of cluster (load sample data)
Please review your course material

You can access browser based IDE at the end of each chapter

1 Like

@Makenna_L , if you go down to the lower-left corner of Compass, there’s a little widget that says >_MONGOSH … click that to get a mongo shell terminal.

1 Like

But that is what I am saying, load doesn’t work in MONGOSH so how am I supposed to load a javascript file?

I am trying to load a javascript file for validation. In the course material, I am told to do it in the mongo shell. The materials had me download a directory with the javascript file and enterprise. I need to use the IDE in the middle of the chapter to do the labs so that won’t work for me. In Compass, when I go to the mongo shell it has, it says that load is not supported in the mongo shell. So how am I supposed to validate my assignments?

Also, I would like to note that in this section there isn’t an IDE like there has been in others. So I can’t access a class IDE, only what I am told to download.

Download legacy mongo shell and load your file
You can load with mongosh also but syntax is different
Check this link

Mongo shell - cant load loadMovieDetailsDataset.js

1 Like