1234567891011121314151617181920212223242526272829 |
- 'use strict';
- const Schema = require('mongoose').Schema;
- const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
- const { Secret } = require('naf-framework-mongoose/lib/model/schema');
- const UserSchema = {
- name: { type: String, required: false, maxLength: 200 },
- mobile: { type: String, required: true, maxLength: 64 },
- passwd: { type: Secret, select: false },
- openid: { type: String, required: false },
- appopenid: { type: String, required: false },
- unionid: { type: String, required: false },
- remark: { type: String, required: false },
- type: { type: String, required: false, maxLength: 200 },
- uid: { type: String, required: false, maxLength: 200 },
- status: { type: String, required: false, default: '0' },
- };
- const schema = new Schema(UserSchema, { toJSON: { virtuals: true } });
- schema.index({ openid: 1 });
- schema.index({ mobile: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('User', schema, 'user');
- };
|