7

I am trying to load a file from folder;

I have a system environment variable as follows

HOME="/home/stack/FolderName"

How can I get this path in js file

$mongo databasename  script.js

in script file

 var data = cat(env.getPath("HOME") +"/requiredData.csv")
 var arr = data.split(",");
 arr.forEach((a) =>  db.collection.insert(a))

data in requireddata.csv is as follows a,b,c,d

thanks in advance.

Mr code.
  • 307
  • 2
  • 17
  • 3
    Please see this post - https://stackoverflow.com/questions/39444467/how-to-pass-environment-variable-to-mongo-script – Clement Amarnath Aug 13 '18 at 12:51
  • Does this answer your question? [how to access mongodb environment variables via mongo shell](https://stackoverflow.com/questions/70603199/how-to-access-mongodb-environment-variables-via-mongo-shell) – varsh Nov 16 '22 at 07:25

0 Answers0