vip.js 770 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 会员表
  7. const vip = {
  8. openid: { type: String }, // 微信openid
  9. name: { type: String }, // 姓名
  10. phone: { type: String }, // 电话
  11. money: { type: Number }, // 金额
  12. remark: { type: String },
  13. };
  14. const schema = new Schema(vip, { toJSON: { virtuals: true } });
  15. schema.index({ id: 1 });
  16. schema.index({ openid: 1 });
  17. schema.index({ name: 1 });
  18. schema.index({ phone: 1 });
  19. schema.index({ 'meta.createdAt': 1 });
  20. schema.plugin(metaPlugin);
  21. module.exports = app => {
  22. const { mongoose } = app;
  23. return mongoose.model('Vip', schema, 'vip');
  24. };