Files

119 lines
3.1 KiB
JavaScript

const mongoose = require("mongoose");
const { Schema } = mongoose;
// Reusable small schemas
const FloatingBadgeSchema = new Schema(
{
icon: { type: String, default: "" },
value: { type: String, default: "" },
label: { type: String, default: "" },
},
{ _id: false },
);
const HeroSchema = new Schema(
{
badge: { type: String, default: "" },
title: { type: String, default: "" },
description: { type: String, default: "" },
searchPlaceholder: { type: String, default: "" },
buttonLabel: { type: String, default: "" },
image: { type: String, default: "" },
imageAlt: { type: String, default: "" },
floatingBadge: { type: FloatingBadgeSchema, default: () => ({}) },
},
{ _id: false },
);
const QuickLinkItemSchema = new Schema(
{
icon: { type: String, default: "" },
title: { type: String, default: "" },
description: { type: String, default: "" },
linkText: { type: String, default: "" },
href: { type: String, default: "" },
},
{ _id: false },
);
const ValuePropFeatureSchema = new Schema(
{
icon: { type: String, default: "" },
title: { type: String, default: "" },
description: { type: String, default: "" },
},
{ _id: false },
);
const ValuePropStatSchema = new Schema(
{
value: { type: String, default: "" },
label: { type: String, default: "" },
image: { type: String, default: "" },
imageAlt: { type: String, default: "" },
},
{ _id: false },
);
const ValuePropSchema = new Schema(
{
badge: { type: String, default: "" },
title: { type: String, default: "" },
description: { type: String, default: "" },
features: { type: [ValuePropFeatureSchema], default: [] },
stats: { type: [ValuePropStatSchema], default: [] },
},
{ _id: false },
);
const ProgramItemSchema = new Schema(
{
category: { type: String, default: "" },
image: { type: String, default: "" },
duration: { type: String, default: "" },
rating: { type: String, default: "" },
title: { type: String, default: "" },
description: { type: String, default: "" },
studentCount: { type: String, default: "" },
href: { type: String, default: "" },
},
{ _id: false },
);
const ProgramsSchema = new Schema(
{
heading: { type: String, default: "" },
description: { type: String, default: "" },
items: { type: [ProgramItemSchema], default: [] },
},
{ _id: false },
);
const RequestInfoSchema = new Schema(
{
heading: { type: String, default: "" },
description: { type: String, default: "" },
phone: { type: String, default: "" },
email: { type: String, default: "" },
programs: { type: [String], default: [] },
},
{ _id: false },
);
const HomeSchema = new Schema(
{
hero: { type: HeroSchema, default: () => ({}) },
quickLinks: { type: [QuickLinkItemSchema], default: [] },
valueProp: { type: ValuePropSchema, default: () => ({}) },
programs: { type: ProgramsSchema, default: () => ({}) },
requestInfo: { type: RequestInfoSchema, default: () => ({}) },
},
{
timestamps: true,
strict: false,
},
);
module.exports = mongoose.model("Home", HomeSchema);