So now that we have created a contacts collection, we can also add arbitrary values for example, I can create a JavaScript variable, let's say work p one equals to an empty object, we want dot name equals to Kumar c one dot email equals to Kumar at you know co p one dot city equals two angle. And now I can add this to the existing collection, which is contacts, I can say now DB dot contacts dot insert, and then I can say p one. Now I have a second record. Now in MongoDB terminologies record is termed as document. And the reason is very simple. In our DBMS, a record consists of rows and columns where every row is of similar columns.
But in case of MongoDB, that's not so now if I say DB dot contacts dot find dot pretty You will see that there are two documents that exist with a different schema or different structure. And if you also have observed, we created the contracts collection without having to define a schema for that. So this is one advantage of MongoDB or any NoSQL databases in general. You can also add arrays of objects. For example, if I can create war, p underscore error equals to an array which is like a square bracket, and then a curly bracket and then I'll say name is john doe. And city is Dallas.
A second one probably name is Jane Doe. City, that's a Chicago and close the bracket. So now p AR is an array so I can check that out. That's an array. And now I can insert this by using the same command again. So DB dot contacts dot insert, and then I'll say P A RR.
Now since I gave an array, it's going to say that there are two documents that got inserted and it also gives me a different response this time this is that bulk right result. There are no errors and number of documents inserted is two and some other useful information. Now I can just say here, db dot contacts dot find dot pretty and you will see all the four documents are intact. If you don't use the predict function, and then just like DB dot contacts dot find, you will see that the output is not so pretty. Now this is true especially if your document structure is very complex and nested and all this stuff. the find function returns a cursor and since we are not collecting That the Mongo shell displays the first 20 documents.
And since we don't have enough documents, we're not seeing that of a difference.