ADD: category model

This commit is contained in:
MohammadHMazarei
2024-12-29 19:32:11 +03:30
parent b67ffb7f5e
commit aff7184e04
+28
View File
@@ -0,0 +1,28 @@
const mongoose = require('mongoose')
const ObjectID = mongoose.Schema.Types.ObjectId
const categorySchema = new mongoose.Schema(
{
nativeName: {
type: String,
required: true,
},
englishName: {
type: String,
required: true,
unique: true,
},
parentId: {
type: ObjectID,
ref: 'Category',
},
},
{
toJSON: { virtuals: true },
toObject: { virtuals: true },
timestamps: true,
}
)
const Category = mongoose.model('Category', categorySchema)
module.exports = Category