Loading .js file using compass

All,

I am using compass to import data using a .js file sitting on my computer. However, all .js files are “greyed out” and I can not do that… Any idea what may be going on?

sanjay

Hi @Sanjay_Gupta_14127,

In Compass, you can import only .json and .csv files.

You can use the load() method in mongo shell to run the .js file.

Hope it helps!

Please feel free to get back to us if you have any other query.

Thanks,
Shubham Ranjan
Curriculum Services Engineer

@Shubham_Ranjan
I tried using the load in cmd but it is giving me an error.


What do I do?
Thanks,
Ajinkya

Please connect to mongo shell and run the command.It will work

Hi @Ajinkya_Meher_70318,

As @Ramachandra_37567 mentioned, you are supposed to run this command inside the mongo shell.

Please connect to your sandbox cluster first and then run the load() method to load dataset into your sandbox cluster.

Hope it helps!

Thanks,
Shubham Ranjan
Curriculum Services Engineer

@Shubham_Ranjan
I am having issues while connecting sandbox


I don’t see the command that is in the Lecture video.
The above screenshot is all I see.

What issue you are facing?
The connect string is shown in your screen shot
Please copy and paste it in shell

I can connect to your Sandbox cluster

1 Like

Hi @Ajinkya_Meher_70318,

What issues are you facing in your sandbox cluster ?

The content shown in the video lecture is a little outdated. The UI has changes since the time of recording the videos.

As @Ramachandra_37567 mentioned, copy and paste the connection string into your shell.

Hope it helps!

Please let me know if you have any other query.

Thanks,
Shubham Ranjan
Curriculum Services Engineer

@Shubham_Ranjan
I am sorry the screenshot was not uploaded in the previous reply.
Following is the error I get when I try to load the .js file from Mongo Shell


Could you please help me?

You are trying to do that on the shared cluster. This should be done in your sandbox cluster.

Hi @steevej-1495
No I am getting confused but I will do the entire thing again and see how it goes.
Thank you for your help!

The …jxeqq… cluster is the shared cluster for M001. The m001-student user has only read privileges on any of the databases. The script loadMovie… does try to modify data on the cluster. That is why you get not authorized … error. The goal of this script is to populate your sandbox cluster with some data. So it has to be run while connected to the sandbox cluster you created earlier in the course. I hope I removed some of the confusion.

You don’t have to redo entire thing
ocxwz is the substring of your Sandbox cluster as shown above in your first snapshot
Please connect to it and try to load the file
It will work

@Shubham_Ranjan @Ramachandra_37567 @steevej-1495
It is working fine now.
Thank you all for your help!

Hi @Ajinkya_Meher_70318,

I’m glad your issue got resolved. Please let me know if you have any other queries.

Thanks,
Shubham Ranjan
Curriculum Services Engineer

Closing this thread as the issue has been resolved.