testmess.js 489 B

12345678910111213141516
  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: true, maxLength: 200 }, // 标题
  7. };
  8. const schema = new Schema(TestmessSchema, { toJSON: { virtuals: true } });
  9. schema.index({ id: 1 });
  10. schema.plugin(metaPlugin);
  11. module.exports = app => {
  12. const { mongoose } = app;
  13. return mongoose.model('Testmess', schema, 'testmess');
  14. };