Chapter 6. Content Management Systems
In this chapter, we’ll look at how you can use MongoDB as a data storage engine for a content management system (CMS). In particular, we’ll examine two main areas of CMS development. Our first use case, Metadata and Asset Management, deals with how we can model our metadata (pages, blog posts, photos, videos) using MongoDB.
Our next use case, Storing Comments, explores several different approaches to storing user comments in a CMS, along with the trade-offs for each approach.
Metadata and Asset Management
In any kind of a content management system, you need to decide on the basic objects that the CMS will be managing. For this section, we’ve chosen to model our CMS on the popular Drupal CMS. (Drupal does have a MongoDB plug-in, but we’ve chosen a simpler implementation for the purposes of illustration in this section.) Here, we explore how MongoDB can be used as a natural data model backend for such a CMS, focusing on the storage of the major types of content in a CMS.
Solution Overview
To build this system, we’ll use MongoDB’s flexible schema to store all
content “nodes” in a single collection nodes regardless of type. This guide
provides prototype schemas and describes common operations for the
following primary node types:
- Basic page
- Basic pages are useful for displaying infrequently changing text such as an About page. With a basic page, the salient information is the title and the content.
- Blog post
- Blog posts are part of a “stream” of ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access