|
@@ -0,0 +1,33 @@
|
|
|
+'use strict';
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
|
+
|
|
|
+
|
|
|
+// 教练
|
|
|
+const coach = {
|
|
|
+ name: { type: String, required: false, zh: '姓名' }, //
|
|
|
+ icon: { type: Array, required: false, zh: '头像' }, //
|
|
|
+ card: { type: String, required: false, zh: '身份证号' }, //
|
|
|
+ gender: { type: String, required: false, zh: '性别' }, //
|
|
|
+ age: { type: Number, required: false, zh: '年龄' }, //
|
|
|
+ phone: { type: String, required: false, zh: '联系电话' }, //
|
|
|
+ major: { type: String, required: false, zh: '专业' }, //
|
|
|
+ level: { type: String, required: false, zh: '等级' }, //
|
|
|
+ brief: { type: String, required: false, zh: '简介' }, // 500字以内
|
|
|
+ honor: { type: String, required: false, zh: '荣誉' }, //
|
|
|
+ exp: { type: String, required: false, zh: '教学经历' }, //
|
|
|
+ user_id: { type: String, required: false, zh: '用户id', ref: 'User', getProp: [ 'name' ] }, //
|
|
|
+};
|
|
|
+const schema = new Schema(coach, { toJSON: { virtuals: true } });
|
|
|
+schema.index({ id: 1 });
|
|
|
+schema.index({ 'meta.createdAt': 1 });
|
|
|
+schema.index({ name: 1 });
|
|
|
+schema.index({ card: 1 });
|
|
|
+schema.index({ level: 1 });
|
|
|
+schema.index({ user_id: 1 });
|
|
|
+
|
|
|
+schema.plugin(metaPlugin);
|
|
|
+module.exports = app => {
|
|
|
+ const conn = app.mongooseDB.get('base');
|
|
|
+ return conn.model('Coach', schema, 'coach');
|
|
|
+};
|