mirror of
https://github.com/cnodejs/nodeclub.git
synced 2025-12-08 19:55:55 +00:00
26 lines
836 B
JavaScript
26 lines
836 B
JavaScript
var mongoose = require('mongoose');
|
|
var Schema = mongoose.Schema;
|
|
var ObjectId = Schema.ObjectId;
|
|
|
|
var TopicSchema = new Schema({
|
|
title: { type: String },
|
|
content: { type: String },
|
|
author_id: { type: ObjectId },
|
|
top: { type: Boolean, default: false },
|
|
reply_count: { type: Number, default: 0 },
|
|
visit_count: { type: Number, default: 0 },
|
|
collect_count: { type: Number, default: 0 },
|
|
create_at: { type: Date, default: Date.now },
|
|
update_at: { type: Date, default: Date.now },
|
|
last_reply: { type: ObjectId },
|
|
last_reply_at: { type: Date, default: Date.now },
|
|
content_is_html: { type: Boolean }
|
|
});
|
|
|
|
TopicSchema.index({create_at: -1});
|
|
TopicSchema.index({top: -1, last_reply_at: -1});
|
|
TopicSchema.index({last_reply_at: -1});
|
|
TopicSchema.index({author_id: 1, create_at: -1});
|
|
|
|
mongoose.model('Topic', TopicSchema);
|