codeitem.js 730 B

12345678910111213141516171819202122
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  4. // 字典表
  5. const CodeitemSchema = {
  6. code: { type: String, required: true, maxLength: 500 }, // code
  7. name: { type: String, required: true, maxLength: 500 }, // 名称
  8. category: { type: String, required: true, maxLength: 500 }, // 类别code
  9. sort: { type: String, required: false, maxLength: 500 }, // 排序
  10. };
  11. const schema = new Schema(CodeitemSchema, { toJSON: { virtuals: true } });
  12. schema.index({ id: 1 });
  13. schema.index({ category: 1 });
  14. schema.plugin(metaPlugin);
  15. module.exports = app => {
  16. const { mongoose } = app;
  17. return mongoose.model('Codeitem', schema, 'code_item');
  18. };