user.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /**
  2. * 用户数据结构
  3. *
  4. * @author CaiAoLin
  5. * @date 2017/6/28
  6. * @version
  7. */
  8. let mongoose = require("mongoose");
  9. let Schema = mongoose.Schema;
  10. // 表名
  11. let collectionName = 'user';
  12. const invalidSchema = new Schema({
  13. invalid: Boolean,
  14. invalidDate: String,
  15. invalidBy: String //管理者名
  16. });
  17. const versionSchema = new Schema({
  18. compilationId: String,
  19. activateCode: String,
  20. activatedDate: String,
  21. activatedBy: String,
  22. invalidInfo: [invalidSchema]
  23. });
  24. // 表结构
  25. let schema = {
  26. ssoId: Number,
  27. username: String,
  28. email: String,
  29. mobile: String,
  30. real_name: {
  31. type: String,
  32. default: ''
  33. },
  34. company: {
  35. type: String,
  36. default: ''
  37. },
  38. province: {
  39. type: Number,
  40. default: -1
  41. },
  42. version: {
  43. type: [versionSchema],
  44. default: []
  45. },
  46. company_type: {
  47. type: Number,
  48. default: -1,
  49. },
  50. company_scale: {
  51. type: Number,
  52. default: -1
  53. },
  54. create_time: Number
  55. };
  56. mongoose.model(collectionName, new Schema(schema, {versionKey: false}));