Mongo bash script to create Db and collections
You need to know that is non required to create the collections, when you start to use it Mongo will create it. On the other hand if you want to create some fixtures into the database assume the collection are already there.
Miton Leon
Updated on June 08, 2022Comments
-
Miton Leon almost 2 years
I'm using vagrant and trying to create some bash sentences to initialize my vagrant local machine like the server configuration:
I'm installing Mongo and everything was ok untill i need to create the database and some collections: I would like to do that:
mongo use redirect db.createCollection("first") db.createCollection("second") db.createCollection("third") exit
From my terminal and conecting to the machine with ssh is working, but i would like to make this process automatic, i have try to run the code exactly like above and is not working. Or something like:
mongo --shell use redirect mongo --shell db.createCollection("first")
If somebody knows how to do this i will appreciate some help.
Thanks in advance.
-
lucasreta about 3 yearscan you provide an explanation to backup your code?