1234567891011121314151617181920212223242526272829 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
- // 学校
- const school = {
- name: { type: String, required: false, zh: '名称' }, //
- brief: { type: String, required: false, zh: '简介' }, //
- phone: { type: String, required: false, zh: '联系方式' }, //
- address: { type: String, required: false, zh: '训练地址' }, //
- coach_num: { type: Number, required: false, default: '0', zh: '教练人数' }, //
- student_num: { type: Number, required: false, default: '0', zh: '学员人数' }, //
- honor: { type: String, required: false, zh: '过往荣誉' }, //
- url: { type: String, required: false, zh: '网址' }, //
- yyzz: { type: Array, required: false, zh: '营业执照' }, //
- img_url: { type: Array, required: false, zh: '图片' }, //
- user_id: { type: String, required: false, zh: '用户表信息', ref: 'User', getProp: [ 'name' ] }, //
- };
- const schema = new Schema(school, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.index({ 'meta.createdAt': 1 });
- schema.index({ name: 1 });
- schema.index({ user_id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('School', schema, 'school');
- };
|