Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb script file

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?

like image 497
Ramya Avatar asked Aug 31 '12 11:08

Ramya


People also ask

Is MongoDB a scripting language?

It is a simple language to learn and feels similar to programming, however it is not programming.

Can I use JavaScript in MongoDB?

MongoDB supports JavaScript through the official Node. js driver. You can connect your Node. js applications to MongoDB and work with your data.


1 Answers

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.

like image 113
Parvin Gasimzade Avatar answered Nov 12 '22 07:11

Parvin Gasimzade