usersessiondata.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. SessionData = new Mongo.Collection('sessiondata');
  2. /**
  3. * A UserSessionData in Wekan. Organization in Trello.
  4. */
  5. SessionData.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. userId: {
  21. /**
  22. * userId of the user
  23. */
  24. type: String,
  25. optional: false,
  26. },
  27. totalHits: {
  28. /**
  29. * total number of hits in the last report query
  30. */
  31. type: Number,
  32. optional: true,
  33. },
  34. lastHit: {
  35. /**
  36. * the last hit returned from a report query
  37. */
  38. type: Number,
  39. optional: true,
  40. },
  41. createdAt: {
  42. /**
  43. * creation date of the team
  44. */
  45. type: Date,
  46. // eslint-disable-next-line consistent-return
  47. autoValue() {
  48. if (this.isInsert) {
  49. return new Date();
  50. } else if (this.isUpsert) {
  51. return { $setOnInsert: new Date() };
  52. } else {
  53. this.unset();
  54. }
  55. },
  56. },
  57. modifiedAt: {
  58. type: Date,
  59. denyUpdate: false,
  60. // eslint-disable-next-line consistent-return
  61. autoValue() {
  62. if (this.isInsert || this.isUpsert || this.isUpdate) {
  63. return new Date();
  64. } else {
  65. this.unset();
  66. }
  67. },
  68. },
  69. }),
  70. );
  71. export default SessionData;