37 lines
865 B
JavaScript
37 lines
865 B
JavaScript
|
const mongoose = require('mongoose');
|
||
|
|
||
|
// Define the schema for the 'subcategories' collection
|
||
|
const subCategoriesSchema = new mongoose.Schema({
|
||
|
CategoriesId: {
|
||
|
type: mongoose.Schema.Types.ObjectId,
|
||
|
ref: 'Category',
|
||
|
required: true
|
||
|
},
|
||
|
categoryName:{
|
||
|
type: String,
|
||
|
},
|
||
|
SubCategoriesName: {
|
||
|
type: String,
|
||
|
required: true
|
||
|
},
|
||
|
image: {
|
||
|
fileName: String,
|
||
|
fileAddress: String,
|
||
|
imageUrl: String
|
||
|
},
|
||
|
|
||
|
|
||
|
status: {
|
||
|
type: String,
|
||
|
enum: ['activate', 'deactivate'],
|
||
|
default: 'activate'
|
||
|
}
|
||
|
}, {
|
||
|
timestamps: true // Add createdAt and updatedAt fields
|
||
|
});
|
||
|
|
||
|
// Create a model based on the schema
|
||
|
const SubCategories = mongoose.model('SubCategories', subCategoriesSchema);
|
||
|
|
||
|
module.exports = SubCategories;
|