Steve Breese

A Chicago-based Full-stack JavaScript Developer

Dynamic Website Content with MongoDB


Building dynamic websites with Node.js and Mongo DB has several advantages over PHP/MySQL driven sites. These include having flexible schemas, higher performance, and less moving parts.

This demo shows a stripped down implementation of obtaining page content from a MongoDB database and displaying it on a page. Here is how it works:

  • Node.js receives incoming HTTPS connection
  • Express router matches URL and fires off code
  • Mongoose forms query and validates it against a collection schema
  • MongoDB interprets the FindOne query and returns page content
  • Express passes the page content along to an EJS template
  • EJS renders the raw string to the template
  • Express & Node.js sends the completed web page to the browser
  • The browser displays the page and runs post-load JavaScript to enable table sorting