12345678910111213141516171819202122 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 字典表
- const CodeitemSchema = {
- code: { type: String, required: true, maxLength: 500 }, // code
- name: { type: String, required: true, maxLength: 500 }, // 名称
- category: { type: String, required: true, maxLength: 500 }, // 类别code
- sort: { type: String, required: false, maxLength: 500 }, // 排序
- };
- const schema = new Schema(CodeitemSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ category: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Codeitem', schema, 'code_item');
- };
|