1234567891011121314151617181920212223242526272829 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 类型
- const typeInfo = new Schema({
- 0: { type: String, required: false, maxLength: 500 }, // 公司新闻
- 1: { type: String, required: false, maxLength: 500 }, // 行业新闻
- 2: { type: String, required: false, maxLength: 500 }, // 展会资讯
- });
- // 热点资讯表
- const hotspot = {
- name: { type: String, required: true, maxLength: 200 }, // 名称
- filepath: { type: String, required: false, maxLength: 200 }, // 图片路径
- create_time: { type: String, required: false, maxLength: 200 }, // 发布时间
- content: { type: String, required: false, maxLength: 500 }, // 内容
- brief: { type: String, required: false, maxLength: 500 }, // 简介
- type: { type: [ typeInfo ], select: true }, // 回答详情
- };
- const schema = new Schema(hotspot, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = (app) => {
- const { mongoose } = app;
- return mongoose.model('Hotspot', schema, 'hotspot');
- };
|