2
0

team.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. Team = new Mongo.Collection('team');
  2. /**
  3. * A Team in Wekan. Organization in Trello.
  4. */
  5. Team.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', 'orgId', 1);
  17. }
  18. },
  19. },
  20. displayName: {
  21. /**
  22. * the name to display for the team
  23. */
  24. type: String,
  25. optional: true,
  26. },
  27. desc: {
  28. /**
  29. * the description the team
  30. */
  31. type: String,
  32. optional: true,
  33. max: 190,
  34. },
  35. name: {
  36. /**
  37. * short name of the team
  38. */
  39. type: String,
  40. optional: true,
  41. max: 255,
  42. },
  43. website: {
  44. /**
  45. * website of the team
  46. */
  47. type: String,
  48. optional: true,
  49. max: 255,
  50. },
  51. createdAt: {
  52. /**
  53. * creation date of the team
  54. */
  55. type: Date,
  56. // eslint-disable-next-line consistent-return
  57. autoValue() {
  58. if (this.isInsert) {
  59. return new Date();
  60. } else if (this.isUpsert) {
  61. return { $setOnInsert: new Date() };
  62. } else {
  63. this.unset();
  64. }
  65. },
  66. },
  67. modifiedAt: {
  68. type: Date,
  69. denyUpdate: false,
  70. // eslint-disable-next-line consistent-return
  71. autoValue() {
  72. if (this.isInsert || this.isUpsert || this.isUpdate) {
  73. return new Date();
  74. } else {
  75. this.unset();
  76. }
  77. },
  78. },
  79. }),
  80. );
  81. if (Meteor.isServer) {
  82. // Index for Team name.
  83. Meteor.startup(() => {
  84. Team._collection._ensureIndex({ name: -1 });
  85. });
  86. }
  87. export default Team;