testmess.js 716 B

12345678910111213141516171819
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 测试信息
  5. const TestmessSchema = {
  6. title: { type: String, required: false, maxLength: 200 }, // 标题
  7. publish_time: { type: String, required: false, maxLength: 200 }, // 发布时间
  8. origin: { type: String, required: false, maxLength: 200 }, // 来源
  9. content: { type: String, required: false, maxLength: 200 }, // 内容
  10. };
  11. const schema = new Schema(TestmessSchema, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.plugin(metaPlugin);
  14. module.exports = app => {
  15. const { mongoose } = app;
  16. return mongoose.model('Testmess', schema, 'testmess');
  17. };