column.js 486 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 ColumnSchema = {
  6. name: { type: String, required: true, maxLength: 500 }, // 栏目名称
  7. };
  8. const schema = new Schema(ColumnSchema, { toJSON: { virtuals: true } });
  9. schema.index({ id: 1 });
  10. schema.plugin(metaPlugin);
  11. module.exports = app => {
  12. const { mongoose } = app;
  13. return mongoose.model('Column', schema, 'column');
  14. };