|
@@ -0,0 +1,33 @@
|
|
|
|
+'use strict';
|
|
|
|
+const Schema = require('mongoose').Schema;
|
|
|
|
+const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
|
|
|
|
+
|
|
|
|
+const { Secret } = require('naf-framework-mongoose-free/lib/model/schema');
|
|
|
|
+
|
|
|
|
+// 顾客
|
|
|
|
+const user = {
|
|
|
|
+ name: { type: String, required: false, zh: '用户名' }, //
|
|
|
|
+ phone: { type: String, required: false, zh: '手机号' }, //
|
|
|
|
+ password: { type: Secret, required: false, select: false, zh: '密码' }, //
|
|
|
|
+ icon: { type: Array, required: false, zh: '头像' }, //
|
|
|
|
+ birth: { type: String, required: false, zh: '生日' }, //
|
|
|
|
+ gender: { type: String, required: false, zh: '性别' }, // 字典:gender
|
|
|
|
+ email: { type: String, required: false, zh: '电子邮箱' }, //
|
|
|
|
+ openid: { type: String, required: false, zh: '微信小程序' }, //
|
|
|
|
+ status: { type: String, required: false, default: '0', zh: '状态' }, // 字典status_status
|
|
|
|
+};
|
|
|
|
+const schema = new Schema(user, { toJSON: { getters: true, virtuals: true } });
|
|
|
|
+schema.index({ id: 1 });
|
|
|
|
+schema.index({ 'meta.createdAt': 1 });
|
|
|
|
+schema.index({ name: 1 });
|
|
|
|
+schema.index({ phone: 1 });
|
|
|
|
+schema.index({ gender: 1 });
|
|
|
|
+schema.index({ openid: 1 });
|
|
|
|
+schema.index({ status: 1 });
|
|
|
|
+
|
|
|
|
+schema.plugin(metaPlugin);
|
|
|
|
+
|
|
|
|
+module.exports = app => {
|
|
|
|
+ const { mongoose } = app;
|
|
|
|
+ return mongoose.model('User', schema, 'user');
|
|
|
|
+};
|