12345678910111213141516171819 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- // 民族表
- const NationSchema = {
- code: { type: String, required: false, maxLength: 500 }, // 代码
- name: { type: String, required: false, maxLength: 500 }, // 名称
- };
- const schema = new Schema(NationSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Nation', schema, 'nation');
- };
|