Dynamic Website Content with MongoDB
Demo
Node.js
Topic | Module |
---|---|
HTTP Module | http, url |
Modules | http |
Upload Files | formidable, http, fs |
URL Module | url, http, fs |
File Handling | fs, http |
NPM | upper-case, http |
Events | fs, events |
nodemailer | |
Assertion Tests | assert |
Binary Data | |
Child Processes | cluster |
OpenSSL | crypto |
DNS Lookups | dns |
UDP Datagram Sockets | dgram |
File System | fs |
HTTP Server | http |
Operating System | os |
Client & Server | net |
HTTPS Server | https |
URL Query Strings | querystring |
Readable/Writable Streams | http, stream |
File Stream | readline |
Decode Binary Data | string_decoder |
Timers | |
String Formatting | util |
URL Strings | http, url |
File Paths | path |
SSL | tls |
Virtual Machine | vm |
File Compression | zlib |
Node.js Database Drivers
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