Files
mbmanager-api/components/category/categoryModel.js
T
2024-12-29 19:32:11 +03:30

29 lines
633 B
JavaScript

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