How to pass environment variable to mongo script

后端 未结 4 635
迷失自我
迷失自我 2020-12-06 01:21

I want to pass the environment variable named file_path to js file.

I am using the following syntax:

mongo --eval \"var file_path=\'$fil         


        
4条回答
  •  天命终不由人
    2020-12-06 02:02

    Looks like Native Method shellGetEnv() has been added meanwhile, see MongoDB GitHub

    So, would be simple

    shellGetEnv("file_path")
    

    However, the method is not documented and it looks it is not accessible from Mongo shell. Perhaps it becomes available in future releases.

提交回复
热议问题