Book Image

Learn Node.js by Building 6 Projects

By : Eduonix Learning Solutions
Book Image

Learn Node.js by Building 6 Projects

By: Eduonix Learning Solutions

Overview of this book

<p>With its event-driven architecture and efficient web services capabilities, more and more companies are building their entire infrastructure around Node.js. Node has become a de facto part of web development that any serious developer needs to master.</p> <p>This book includes six Node.js projects that gradually increase in complexity. You'll start by building a simple web server and create a basic website. You will then move to create the login system, blog system, chat system, and e-learning system.</p> <p>By creating and following the example projects in this book, you’ll improve your Node.js skills through practical working projects, and you'll learn how to use Node.js with many other useful technologies, such as ExpressJS, Kickstart, and Heroku.</p>
Table of Contents (12 chapters)

Getting started with MongoDB – part B


In the last section we went ahead and installed MongoDB, I showed you how to log into the shell and create a database, as well as create a collection. Now what we'll do is create the database for our application, for our nodeauth application. We'll insert some data and I'll also show you how to fetch that data from the shell.

Data fetching from the shell

So let's create a new database:

  1. To do that we can simply use use and then name it. I'm going to call this nodeauth:
      use nodeauth
  1. You can see we switch to nodeauth and we want to create a collection called users. Let's say db.createCollection and I'll call this users:
      db.createCollection('users');

We'll run that and now if we say show collections we have users.

  1. Now to insert a user, we can simply use db.users.insert and then insert a document, which is basically just a JSON object. So we need our curly braces and the first thing we'll give it is a name, I'll use my name.
  2. The next thing we want is email...