Example blog made with MongoDB



ZWfCUiXKLM

View by objectId ( 531904eb62365b020032ea5f)
By Rachel on Thu Mar 06 2014 23:29:47 GMT+0000 (UTC)

ItBwNkcxiBqXXOjzF

View by objectId ( 531200acf751b102001d82f2)
By Luke on Sat Mar 01 2014 15:45:48 GMT+0000 (UTC)

QVMRylKrrmqMGwUZrGk

View by objectId ( 50884c3e58e0a36c1d000002)
By Julia on Wed Oct 24 2012 20:14:54 GMT+0000 (UTC)

Code sample - how all blog posts were queried

// from web.js
// main page - display all blog posts
// More Mongoose query information here
// http://mongoosejs.com/docs/finding-documents.html

app.get('/', function(request, response) {

    // build the query
    var query = BlogPost.find({});
    query.sort('date',-1); //sort by date in descending order

    // run the query and display blog_main.html template if successful
    query.exec({}, function(err, allPosts){

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

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

    });

});
// end of main page