observableChanges.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. class Message {
  2. constructor(userId, type, method, doc, selector, fieldNames, modifier) {
  3. this.userId = userId;
  4. this.type = type;
  5. this.method = method;
  6. this.doc = doc;
  7. this.selector;
  8. this.fieldNames = fieldNames;
  9. this.modifier = modifier;
  10. }
  11. }
  12. //------------- CARDS --------------------
  13. Cards.before.update(function (userId, doc, fieldNames, modifier, options) {
  14. Winston.log('info', new Message(userId, 'card', 'update', doc, null, fieldNames, modifier));
  15. });
  16. Cards.before.remove(function (userId, doc) {
  17. Winston.log('info', new Message(userId, 'card', 'remove', doc));
  18. });
  19. Cards.before.insert(function (userId, doc) {
  20. Winston.log('info', new Message(userId, 'card', 'insert', doc));
  21. });
  22. Cards.before.upsert(function (userId, selector, modifier, options) {
  23. Winston.log('info', new Message(userId, 'card', 'update', null, selector, null, modifier));
  24. });
  25. //------------- BOARDS --------------------
  26. Boards.before.update(function (userId, doc, fieldNames, modifier, options) {
  27. Winston.log('info', new Message(userId, 'board', 'update', doc, null, fieldNames, modifier));
  28. });
  29. Boards.before.remove(function (userId, doc) {
  30. Winston.log('info', new Message(userId, 'board', 'remove', doc));
  31. });
  32. Boards.before.insert(function (userId, doc) {
  33. Winston.log('info', new Message(userId, 'board', 'insert', doc));
  34. });
  35. Boards.before.upsert(function (userId, selector, modifier, options) {
  36. Winston.log('info', new Message(userId, 'board', 'update', null, selector, null, modifier));
  37. });
  38. //------------- LISTS --------------------
  39. Lists.before.update(function (userId, doc, fieldNames, modifier, options) {
  40. Winston.log('info', new Message(userId, 'list', 'update', doc, null, fieldNames, modifier));
  41. });
  42. Lists.before.remove(function (userId, doc) {
  43. Winston.log('info', new Message(userId, 'list', 'remove', doc));
  44. });
  45. Lists.before.insert(function (userId, doc) {
  46. Winston.log('info', new Message(userId, 'list', 'insert', doc));
  47. });
  48. Lists.before.upsert(function (userId, selector, modifier, options) {
  49. Winston.log('info', new Message(userId, 'list', 'update', null, selector, null, modifier));
  50. });
  51. //------------- CARD COMMENTS --------------------
  52. CardComments.before.update(function (userId, doc, fieldNames, modifier, options) {
  53. Winston.log('info', new Message(userId, 'card-comments', 'update', doc, null, fieldNames, modifier));
  54. });
  55. CardComments.before.remove(function (userId, doc) {
  56. Winston.log('info', new Message(userId, 'card-comments', 'remove', doc));
  57. });
  58. CardComments.before.insert(function (userId, doc) {
  59. Winston.log('info', new Message(userId, 'card-comments', 'insert', doc));
  60. });
  61. CardComments.before.upsert(function (userId, selector, modifier, options) {
  62. Winston.log('info', new Message(userId, 'card-comments', 'update', null, selector, null, modifier));
  63. });
  64. //------------- USERS --------------------
  65. Users.before.update(function (userId, doc, fieldNames, modifier, options) {
  66. Winston.log('info', new Message(userId, 'user', 'update', doc, null, fieldNames, modifier));
  67. });
  68. Users.before.remove(function (userId, doc) {
  69. Winston.log('info', new Message(userId, 'user', 'remove', doc));
  70. });
  71. Users.before.insert(function (userId, doc) {
  72. Winston.log('info', new Message(userId, 'user', 'insert', doc));
  73. });
  74. Users.before.upsert(function (userId, selector, modifier, options) {
  75. Winston.log('info', new Message(userId, 'user', 'update', null, selector, null, modifier));
  76. });