123456789101112131415161718192021222324 |
- '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 = {
- uid: { type: String, required: false, maxLength: 200 }, // 用户信息表id
- openid: { type: String, required: false, maxLength: 200 }, // 用户微信openid
- passwd: { type: { Secret }, required: true, select: false, maxLength: 200 }, // 用户密码
- role_id: { type: String, required: false, maxLength: 200 }, // 用户权限id
- name: { type: String, required: false, maxLength: 200 }, // 用户名
- phone: { type: String, required: true, maxLength: 64 }, // 手机号
- };
- const schema = new Schema(UserSchema, { toJSON: { virtuals: true } });
- schema.index({ id: 1 });
- schema.plugin(metaPlugin);
- module.exports = app => {
- const { mongoose } = app;
- return mongoose.model('User', schema, 'user');
- };
|