mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-26 13:20:41 +03:00
16 lines
414 B
JavaScript
16 lines
414 B
JavaScript
|
const mongoose = require("mongoose")
|
||
|
|
||
|
const schema = new mongoose.Schema({
|
||
|
name: { type: String, unique: true },
|
||
|
desp: String, position: Number,
|
||
|
id: { type: String, unique: true },
|
||
|
authorID: { type: String }
|
||
|
|
||
|
});
|
||
|
schema.methods.takeId = async function () {
|
||
|
this.id = String(await model.count() || 0);
|
||
|
return this;
|
||
|
}
|
||
|
const model = mongoose.model('category', schema);
|
||
|
|
||
|
module.exports = model;
|