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.
For instance
CREATE DATABASE `sandbox`;
USE `sandbox`;
CREATE TABLE pet (
name VARCHAR(20),
owner VARCHAR(20),
species VARCHAR(20),
sex CHAR(1),
birth DATE,
death DATE
);
SHOW TABLES;
Then it can be execute as
$ mysql -u root -p admin
mysql > source test.sql;
Questions
- How can we do that in mongodb?
- Which type of file can we store
mongodbcommands? - How can we execute a
mongodbscript?
You can do it with shell script. You can execute the commands using the following command.
For details check Scripting the shell document in Mongo docs.