interviews

Illustration By: testttt
8 December, 2025
import mongoose from "mongoose";
const postSchema = new mongoose.Schema(
{
type: {
type: String,
enum: [
"post",
"interviews",
"in-focus",
"word-of-mouth",
"in-retrospect",
"sdg-spotlight",
"features",
],
required: true,
default: "post",
},
title: {
type: String,
required: true,
},
slug: {
type: String,
required: true,
},
subTitle: {
type: String,
},
author: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Author",
required: false,
},
],
datePosted: {
type: Date,
default: Date.now,
},
illustration: {
type: mongoose.Schema.Types.ObjectId,
ref: "IllustrationAuthor",
required: false,
},
description: [
{
type: {
type: String,
enum: ["text", "ad"],
required: true,
},
content: {
text: {
type: String,
required: function () {
return this.type === "text";
},
},
ad: {
type: mongoose.Schema.Types.ObjectId,
ref: "Ad",
required: function () {
return this.type === "ad";
},
},
},
},
],
image: {
type: String,
required: true,
},
isActive: {
type: Boolean,
default: true,
},
category: {
type: mongoose.Schema.Types.ObjectId,
ref: "Category",
},
isFeatured: {
type: Boolean,
default: false,
},
precedence: {
type: Number,
// required: true,
},
},
{ timestamps: true }
);
const Post = mongoose.model("Post", postSchema);
export default Post;