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...