Example blog made with MongoDB



<% for(i=0; i

<%= posts[i].title %>

View by objectId ( <%= posts[i]._id %>)
By <%= posts[i].author.name %> on <%= posts[i].date %>
<% } %>

Code sample - recent posts from the last week

            app.get("/recent", function(request, response){

                // create date variable for 7 days ago
                var lastWeek = new Date();
                lastWeek.setDate(-7);

                // query for all blog posts where the date is greater than or equal to 7 days ago
                var query = BlogPost.find({ date : { $gte: lastWeek }});

                query.sort('date',-1);
                query.exec(function (err, recentPosts) {


                  // prepare template data
                  templateData = {
                      posts : recentPosts
                  };

                  // render the card_form template with the data above
                  response.render('recent_posts.html', templateData);

                });

            });