1234567891011121314151617181920212223242526272829303132 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const moment = require('moment');
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- const { ObjectId } = require('mongoose').Types;
- const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
- // 机构表
- const mechanism = {
- name: { type: String }, // 机构名
- contacts: { type: String }, // 联系人
- phone: { type: String }, // 联系电话
- passwd: { type: Secret, select: false }, // 密码
- email: { type: String }, // 电子邮箱
- address: { type: String }, // 联系地址
- industry: { type: String }, // 所属行业
- // 21-05-07添加区字段
- juris: { type: String }, // 辖区
- status: { type: String, required: false, default: '0', maxLength: 200 }, // 审核状态,0-注册,1-通过,2-拒绝
- isdel: { type: String, required: false, default: '0' }, // 0=>未删除;1=>已删除
- remark: { type: String },
- create_time: { type: String },
- };
- const schema = new Schema(mechanism, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ name: 1 });
- schema.index({ industry: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('Mechanism', schema, 'mechanism');
- };
|