Hey,
I am using mongoDB and am curious to whether you can import scripts like you can in MySQL:
mysql -uuser -ppassword database < script.sql
Can you do this with mongoDB?
Cheers
Eef
Hey,
I am using mongoDB and am curious to whether you can import scripts like you can in MySQL:
mysql -uuser -ppassword database < script.sql
Can you do this with mongoDB?
Cheers
Eef
You can use mongoimport, a utility that ships with mongodb. Here are some docs:
There's also mongodump and mongorestore.
You can pass a list of JS files to the mongo JavaScript shell and those will get executed:
$ echo "print('hello');" > test.js
$ ./mongo test.js
MongoDB shell version: 1.3.2-
url: test
connecting to: test
hello
You can use the normal mongo command line arguments if you need to specify a specific db, username, or password like you do in your above example.