Overview
This page documents the internal Wiki and WikiPage schemas used by the LiveGobe Wiki System backend.
These Mongoose schemas define the structure, validation, and relationships between wiki instances and their content pages.
Wiki Schema
The Wiki schema represents an individual wiki site — including its configuration, language, and creation metadata.
const WikiSchema = new mongoose.Schema({
name: {
type: String,
required: true,
unique: true,
match: /^[a-z0-9-]+$/, // Only lowercase letters, numbers, hyphens
trim: true
},
language: {
type: String,
required: true,
default: "en"
},
title: {
type: String,
required: true,
trim: true
},
description: {
type: String,
trim: true
},
settings: {
theme: { type: String, default: "default" },
allowAnonymousRead: { type: Boolean, default: true },
allowAnonymousEdit: { type: Boolean, default: true },
defaultLayout: { type: String, default: "default" }
},
createdAt: { type: Date, default: Date.now },
updatedAt: { type: Date, default: Date.now }
});
| Field | Type | Description |
|---|---|---|
name | String | Unique lowercase ID of the wiki (e.g. my-wiki). |
language | String | Default language code for this wiki. |
title | String | Display title shown in the header and metadata. |
description | String | Optional text shown on main or about pages. |
settings.theme | String | Theme name (Currently unused). |
settings.allowAnonymousRead | Boolean | Allows public viewing if true. |
settings.allowAnonymousEdit | Boolean | Allows all registered users to edit the pages if true. |
settings.defaultLayout | String | Default page layout template (Currently unused). |
createdAt | Date | Creation timestamp. |
updatedAt | Date | Last modification timestamp. |
WikiPage Schema
The WikiPage schema defines all content pages stored within a wiki.
Each page includes version tracking, categorization, and relationships with templates and categories.
const RevisionSchema = new mongoose.Schema({
content: { type: String, required: true },
comment: { type: String, default: "" },
author: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },
timestamp: { type: Date, default: Date.now },
minor: { type: Boolean, default: false }
});
const WikiPageSchema = new mongoose.Schema({
wiki: { type: mongoose.Schema.Types.ObjectId, ref: 'Wiki', required: true, index: true },
title: { type: String, required: true, trim: true },
namespace: { type: String, required: true, default: "Main", enum: utils.getSupportedNamespaces(), index: true },
path: { type: String, required: true, trim: true },
content: { type: String, required: true, default: "" },
html: { type: String },
revisions: [RevisionSchema],
createdAt: { type: Date, default: Date.now },
createdBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },
lastModifiedAt: { type: Date, default: Date.now },
lastModifiedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User', required: true },
categories: [{ type: String, ref: 'WikiPage', index: true }],
tags: [{ type: String, index: true }],
templateUsedBy: [{ type: mongoose.Schema.Types.ObjectId, ref: 'WikiPage' }],
templatesUsed: [{ type: mongoose.Schema.Types.ObjectId, ref: 'WikiPage' }],
protected: { type: String, enum: ["none", "edit", "move", "full"], default: "none" },
isPurging: { type: Boolean, default: false, select: false },
pagesUsingCategory: [{ type: mongoose.Schema.Types.ObjectId, ref: 'WikiPage' }]
});
| Field | Type | Description |
|---|---|---|
wiki | ObjectId (Wiki) | Reference to the parent wiki. |
title | String | Page title, unique per namespace. |
namespace | String | Page namespace (e.g. Main, Template, Module). |
path | String | Full hierarchical path (e.g. Parent/Child/Subpage). |
content | String | Raw source text of the page. |
html | String | Rendered HTML output. |
revisions | Array of Revision | History of content edits. |
createdBy / lastModifiedBy | ObjectId (User) | References to authors. |
categories | [String] | List of categories the page belongs to. |
tags | [String] | Custom tags for filtering and search. |
templateUsedBy | [ObjectId] | Pages that use this as a template. |
templatesUsed | [ObjectId] | Templates used by this page. |
protected | String (enum) | Restriction level: "none", "edit", "move", "full". |
isPurging | Boolean | Temporary flag for purge operations (hidden by default). |
pagesUsingCategory | [ObjectId] | Currently unused. |
Revision Schema
Each revision records a single saved version of a page.
| Field | Type | Description |
|---|---|---|
content | String | Snapshot of the page content. |
comment | String | Edit summary. |
author | ObjectId (User) | Author reference. |
timestamp | Date | When the revision was created. |
minor | Boolean | Whether the edit was marked as minor. |
Relationships
| From | To | Type | Description |
|---|---|---|---|
| Wiki | WikiPage | One-to-Many | Each wiki contains multiple pages. |
| WikiPage | Revision | One-to-Many | A page has multiple content revisions. |
| WikiPage | WikiPage (Template) | Many-to-Many | Pages may use other pages as templates. |
| WikiPage | WikiPage (Category) | Many-to-Many | Category pages can list other pages. |
Notes
- Pages with
protectedset to"full"can only be edited by admins. - The field
isPurgingis hidden from normal queries to avoid interference during cleanup. - Categories and templates are dynamically updated through backend hooks.