12345678910111213141516171819202122 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 信息表
- const NewsSchema = {
- column_id: { type: String, required: true, maxLength: 500 }, // 栏目id
- title: { type: String, required: true, maxLength: 500 }, // 标题
- orgin: { type: String, required: true, maxLength: 500 }, // 来源
- content: { type: String, required: true }, // 正文
- picture: { type: String, required: false }, // 图片路径
- };
- const schema = new Schema(NewsSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('News', schema, 'serve_news');
- };
|