Files
ai-dimension/server/src/models/Trend.js
T

37 lines
1.2 KiB
JavaScript

const mongoose = require('mongoose');
const { Schema } = mongoose;
const TrendSchema = new Schema({
title: { type: String, required: true, trim: true },
summary: { type: String },
body: { type: String },
source: { type: String, default: '未知来源' },
sourceUrl: { type: String },
category: {
type: String,
enum: ['产品', '论文', '工具', '公司', '政策', '其他'],
default: '其他'
},
tags: [String],
hot: { type: Boolean, default: false },
// 人话解读(AI 生成,治"看不懂AI新闻"的焦虑)
plainExplain: { type: String, default: '' }, // 一句话说清这是什么
takeAway: { type: String, default: '' }, // 对普通人意味着什么
picked: { type: Boolean, default: false },
newsDate: { type: Date, default: Date.now, index: true },
viewCount: { type: Number, default: 0 },
status: {
type: String,
enum: ['draft', 'published'],
default: 'published'
}
}, {
timestamps: true,
toJSON: { virtuals: true },
toObject: { virtuals: true }
});
TrendSchema.index({ status: 1, newsDate: -1 });
TrendSchema.index({ category: 1, newsDate: -1 });
module.exports = mongoose.model('Trend', TrendSchema);