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