[00:00] In order to create a new Mongo collection, we have two choices. Either we use the GUI, the Mongo compass, and here we can hover over the database name over here and use the plus icon, which points us to the create collection form, Or we can actually walk into this database over here and we will have the button that does exactly the same Or we can use the Mongo shell to learn the Mongo API, which we're going to need anyway at some point So by opening the shell here, we have use local. So we're using the database which has the local name, and here we're going to use the JavaScript language which is native to mongoshell. So there is a predefined db variable which points to the database that has been already chosen. Now the existing collections such as the startup log will be available under the keys of this db object.
[01:00] We'll create a new collection by running the db.createCollection() and here we pass what is going to be the name of the new collection that we pass using a string, so in our case this is going to be employees. So by Receiving the ok1 it means that the command was successful and now we would just need to go to this tab Which displays our collections and refresh it in order to see that there is a new collection which has some storage Already, but it has no documents. No average document size. There is one index for the ID obviously but anyway this collection is empty. What is important at this point is that we're creating a collection by specifying no details whatsoever so there is no schema within the Mongo collection that we need to pass so unlike SQL we don't need to say what are the columns what are the properties of the documents nothing like this so the structure is not rigged We can push pretty much almost anything that we want into the collection and this will not require us to push the object of the same shape.
[02:12] Also if we want to change the shape of the documents then we don't need to run anything like alter table or alter collection, nothing like that. So the collection does exist. Now we can also see that there is nothing within the collection so let's run DB and now we can walk into the employees collection because it already exists and just for example we can run the find command which is going to show that there are no documents here or we can run the count documents command and again there are no documents here whatsoever. So if we want to remove the collection, again, if we want into the database itself, then we could try to drop the collection from the graphical user interface or we can run an appropriate command and in this case this is going to be db employees and here there is a drop command that we can run over here So if that's true and we walk into this database tab and we click refresh, then we can see that our employees collection is gone. However, I will quickly recreate this collection for the sake of future lessons.
[03:31] So create collection and here it is.