-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Learning Node.js for Mobile Application Development
By :

Now that we have created a database, let's populate it with some collections by performing the following steps:
Run the following to create a collection for Products
:
> db.createCollection('Products')
MongoDB will respond with the following:
{ "ok" : 1 }
The preceding code indicates that the command was executed successfully. Note that the response is returned to us in the JSON format.
Let's pause for a minute and break down the preceding command so that we understand what we just did:
The db
is a JavaScript object that represents the currently selected database. In our case, it is OrderBase
.
The createCollection('Products')
function is one of the many member methods of db
. Needless to say, it creates a new collection and adds it to db
. Its parameter, a string, is the name of the new collection.
In other words, working with MongoDB is actually a matter of issuing commands in pure JavaScript. Not only that, but the data itself and the responses to the commands are encoded...
Change the font size
Change margin width
Change background colour