ADD: category model
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user