org.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. Org = new Mongo.Collection('org');
  2. /**
  3. * A Organization in wekan
  4. */
  5. Org.attachSchema(
  6. new SimpleSchema({
  7. id: {
  8. /**
  9. * the organization id
  10. */
  11. type: Number,
  12. optional: true,
  13. // eslint-disable-next-line consistent-return
  14. autoValue() {
  15. if (this.isInsert && !this.isSet) {
  16. return incrementCounter('counters', 'org_id', 1);
  17. }
  18. },
  19. },
  20. version: {
  21. /**
  22. * the version of the organization
  23. */
  24. type: Number,
  25. optional: true,
  26. },
  27. name: {
  28. /**
  29. * name of the organization
  30. */
  31. type: String,
  32. optional: true,
  33. max: 190,
  34. },
  35. address1: {
  36. /**
  37. * address1 of the organization
  38. */
  39. type: String,
  40. optional: true,
  41. max: 255,
  42. },
  43. address2: {
  44. /**
  45. * address2 of the organization
  46. */
  47. type: String,
  48. optional: true,
  49. max: 255,
  50. },
  51. city: {
  52. /**
  53. * city of the organization
  54. */
  55. type: String,
  56. optional: true,
  57. max: 255,
  58. },
  59. state: {
  60. /**
  61. * state of the organization
  62. */
  63. type: String,
  64. optional: true,
  65. max: 255,
  66. },
  67. zip_code: {
  68. /**
  69. * zip_code of the organization
  70. */
  71. type: String,
  72. optional: true,
  73. max: 50,
  74. },
  75. country: {
  76. /**
  77. * country of the organization
  78. */
  79. type: String,
  80. optional: true,
  81. max: 255,
  82. },
  83. billing_email: {
  84. /**
  85. * billing_email of the organization
  86. */
  87. type: String,
  88. optional: true,
  89. max: 255,
  90. },
  91. createdAt: {
  92. /**
  93. * creation date of the organization
  94. */
  95. type: Date,
  96. // eslint-disable-next-line consistent-return
  97. autoValue() {
  98. if (this.isInsert) {
  99. return new Date();
  100. } else {
  101. this.unset();
  102. }
  103. },
  104. },
  105. modifiedAt: {
  106. type: Date,
  107. denyUpdate: false,
  108. // eslint-disable-next-line consistent-return
  109. autoValue() {
  110. if (this.isInsert || this.isUpsert || this.isUpdate) {
  111. return new Date();
  112. } else {
  113. this.unset();
  114. }
  115. },
  116. },
  117. }),
  118. );
  119. export default Org;