familyModel.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use strict';
  2. module.exports = app => {
  3. const mongoose = app.mongoose;
  4. const Schema = mongoose.Schema;
  5. const FamilySchema = new Schema({
  6. dept1: {
  7. type: Schema.Types.ObjectId,
  8. ref: 'sysDept',
  9. },
  10. dept2: {
  11. type: Schema.Types.ObjectId,
  12. ref: 'sysDept',
  13. },
  14. dept3: {
  15. type: Schema.Types.ObjectId,
  16. ref: 'sysDept',
  17. },
  18. dept4: {
  19. type: Schema.Types.ObjectId,
  20. ref: 'sysDept',
  21. },
  22. dept5: {
  23. type: Schema.Types.ObjectId,
  24. ref: 'sysDept',
  25. },
  26. userid: {
  27. type: Schema.Types.ObjectId,
  28. ref: 'sysUser',
  29. },
  30. // userName: { type: String }, // 采集员
  31. time: { type: Date, default: Date.now },
  32. openId: { type: Array }, // 赡养人微信openid
  33. // appletId: { type: Array }, // 赡养人小程序openid
  34. });
  35. FamilySchema.index({ userid: 1 }, { background: true, name: 'family_userid_1' });
  36. FamilySchema.index({ time: 1 }, { background: true, name: 'family_time_1' });
  37. FamilySchema.index({ openId: 1 }, { background: true, name: 'family_openId_1' });
  38. return mongoose.model('Family', FamilySchema, 'family');
  39. };