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)

Homepage posts display


In this section, I want to display posts on our Home page, but first we need to add some and we will use the Mongo shell to do this:

Let's go into a Windows Command Prompt here and go to our mongodb folder and then inside the bin folder:

Now let's run mongo. We're now inside a shell, and we'll create a new database by saying use nodeblog; this will create the shell and it's will put us inside of it:

Next, we'll create two collections, one of which we'll call db.createCollection and the other, categories; we'll also create another one and call it posts:

Now we have a comment functionality, but we'll not create a comments collection; I'll show you how we can actually embed comments inside our post collection.

We will first enter db. I'll just only few posts, so enter db.posts.insert; we will put a couple of things in here. We need to have title, and we'll just say Blog Post One. We will also have category, and for this, let's say Technology (I'll actually use double quotes...