17 lines
858 B
JavaScript
17 lines
858 B
JavaScript
const mongoose = require('mongoose');
|
|
|
|
const categorySchema = new mongoose.Schema({
|
|
name: { type: String, required: true, trim: true, unique: true },
|
|
slug: { type: String, required: true, unique: true, lowercase: true },
|
|
description: { type: String, default: '' },
|
|
image: { type: String, default: 'https://images.unsplash.com/photo-1510915361894-db8b60106cb1?w=600' },
|
|
homeImage: { type: String, default: '' },
|
|
fallbackImage: { type: String, default: 'https://images.unsplash.com/photo-1510915361894-db8b60106cb1?w=600' },
|
|
parentCategory: { type: mongoose.Schema.Types.ObjectId, ref: 'Category', default: null },
|
|
displayOrder: { type: Number, default: 0 },
|
|
isFeaturedHome: { type: Boolean, default: true },
|
|
isActive: { type: Boolean, default: true }
|
|
}, { timestamps: true });
|
|
|
|
module.exports = mongoose.model('Category', categorySchema);
|