How do you run the mongo script shell with the deployed meteor application?

With mongo, you can write scripts that are passed to the shell, for example:

mongo myDB script.js 

http://docs.mongodb.org/manual/tutorial/write-scripts-for-the-mongo-shell/

but to access the mongo shell of the deployed meteor application the following is said:

 meteor mongo myApp.meteor.com 

I cannot transfer a script file with this statement as follows:

  meteor mongo myApp.meteor.com script.js 

because my deployed application is password protected and the above statement passes script.js to the password prompt.

So the question is, how do you do this?

Alternatively, how can you connect to the expanded mongo shell of the meteor application without using a meteor?

+4
source share
2 answers

Get instance registration data through meteor mongo myapp.meteor.com --url . You will get what should fit

MongoDB: // username : password @ host : port / databasename

What you can use to log in via mongo to your computer. Remember that the login details lasted only 1 minute, after which you need meteor mongo --url

 mongo host:port/databasename -u username -p password yourscript.js 
+8
source

Expand the bit on Akshat's answer. The URI string that meteor mongo --url is the MongoDB Connection String . It's a little surprising that the mongo shell itself does not support this format. This has been reported as an error ; also see this answer .

It would be nice if meteor mongo had a way to pass parameters not directly related to the mongo shell. Following the common Unix idiom, it might be something like this:

 meteor mongo myapp.meteor.com -- myscript.js --some-other-mongo-parameter 

But this does not work (I sent a function request ).

I wrote a handy wrapper for all mongo shell shell commands. You can install it using NPM:

 npm install -g mmongo 

If you are not using NPM, this is just one file that needs to be dropped somewhere in your $PATH ; see README on Github .

Now you can do:

 mmongo myapp.meteor.com myscript.js 

Also see this answer for some examples.

(In Ruby, there was previously a less recognized script, see this Gist .)

+2
source

Source: https://habr.com/ru/post/1485268/


All Articles