mongodb script file

Ramya picture Ramya · Aug 31, 2012 · Viewed 7k times · Source

I am newbie to mongodb.

We can execute list of queries by specifying it in a script .sql file in relational db and can run it by running the command source c:\test.sql.

How can we do that in mongodb? how to store those commands in mongodb script and how to execute in mongodb?

Answer

Parvin Gasimzade picture Parvin Gasimzade · Aug 31, 2012

You can do it with shell script. You can execute the commands using the following command.

./mongo server:27017/dbname --quiet my_commands.js

For details check Scripting the shell document in Mongo docs.