2017-07-03 13:48:32 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Module dependencies
|
|
|
|
|
*/
|
|
|
|
|
var mongoose = require('mongoose'),
|
|
|
|
|
Schema = mongoose.Schema;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Forum Schema
|
|
|
|
|
*/
|
|
|
|
|
var ForumSchema = new Schema({
|
|
|
|
|
name: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '',
|
|
|
|
|
trim: true
|
|
|
|
|
},
|
|
|
|
|
desc: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '',
|
|
|
|
|
trim: true
|
|
|
|
|
},
|
|
|
|
|
img: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: '',
|
|
|
|
|
trim: true
|
|
|
|
|
},
|
|
|
|
|
order: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 0
|
|
|
|
|
},
|
|
|
|
|
readOnly: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
default: false
|
|
|
|
|
},
|
2017-07-03 18:15:11 +08:00
|
|
|
category: {
|
|
|
|
|
type: String,
|
|
|
|
|
default: 'discuss',
|
|
|
|
|
trim: true
|
|
|
|
|
},
|
2017-07-03 13:48:32 +08:00
|
|
|
|
|
|
|
|
topicCount: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 0
|
|
|
|
|
},
|
|
|
|
|
replyCount: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 0
|
|
|
|
|
},
|
|
|
|
|
|
2017-07-08 00:08:55 +08:00
|
|
|
lastTopic: {
|
2017-07-03 13:48:32 +08:00
|
|
|
type: Schema.Types.ObjectId,
|
|
|
|
|
ref: 'Topic'
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
moderators: [{
|
|
|
|
|
type: Schema.Types.ObjectId,
|
|
|
|
|
ref: 'User'
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
|
|
createdAt: {
|
|
|
|
|
type: Date,
|
|
|
|
|
default: Date.now
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
mongoose.model('Forum', ForumSchema);
|