wxUserCache.js 743 B

123456789101112131415161718192021
  1. 'use strict';
  2. const Schema = require('mongoose').Schema;
  3. const moment = require('moment');
  4. const metaPlugin = require('naf-framework-mongoose-free/lib/model/meta-plugin');
  5. const { ObjectId } = require('mongoose').Types;
  6. // 微信公众号关注用户表
  7. const wxUserCache = {
  8. wxopenid: { type: String }, // 公众号id
  9. unionid: { type: String }, // 开放平台id
  10. remark: { type: String },
  11. };
  12. const schema = new Schema(wxUserCache, { toJSON: { virtuals: true } });
  13. schema.index({ id: 1 });
  14. schema.index({ wxopenid: 1 });
  15. schema.index({ unionid: 1 });
  16. schema.index({ 'meta.createdAt': 1 });
  17. schema.plugin(metaPlugin);
  18. module.exports = app => {
  19. const { mongoose } = app;
  20. return mongoose.model('WxUserCache', schema, 'wxUserCache');
  21. };