'use strict'; const Schema = require('mongoose').Schema; const moment = require('moment'); const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin'); const { ObjectId } = require('mongoose').Types; // 会员表 const vip = { openid: { type: String }, // 微信openid name: { type: String }, // 姓名 phone: { type: String }, // 电话 money: { type: Number }, // 金额 remark: { type: String }, }; const schema = new Schema(vip, { toJSON: { virtuals: true } }); schema.index({ id: 1 }); schema.index({ openid: 1 }); schema.index({ name: 1 }); schema.index({ phone: 1 }); schema.index({ 'meta.createdAt': 1 }); schema.plugin(metaPlugin); module.exports = app => { const { mongoose } = app; return mongoose.model('Vip', schema, 'vip'); };