@dhyasama/totem-models 2.1.1 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/Interaction.js +20 -3
  2. package/package.json +1 -1
@@ -13,7 +13,7 @@ module.exports = function(mongoose, config) {
13
13
  var Interaction = new Schema({
14
14
 
15
15
  calendarEventId: { type: Schema.ObjectId, ref: 'CalendarEvent', required: true }, // the event from the original pull
16
- providerEventId: { type: String, required: true, index: true, trim: true, unique: true }, // unique id from the calendar provider
16
+ providerEventId: { type: String, required: true, index: true, trim: true }, // unique id from the calendar provider
17
17
  totemCustomerId: { type: Schema.ObjectId, ref: 'Organization', index: true, required: true },
18
18
  summary: { type: String, required: true, trim: true },
19
19
  startTime: { type: Date, index: true },
@@ -90,7 +90,7 @@ module.exports = function(mongoose, config) {
90
90
  // because it will alter the pages
91
91
  options.sort = options.sort || {'startTime': -1};
92
92
  options.before = options.before || moment().toISOString();
93
- options.after = options.after || moment().subtract(1, 'year').toISOString();
93
+ options.after = options.after || moment().subtract(2, 'year').toISOString();
94
94
 
95
95
  var query = self.find({ totemCustomerId: config.CUSTOMER_ID });
96
96
 
@@ -103,6 +103,13 @@ module.exports = function(mongoose, config) {
103
103
  path: 'notes',
104
104
  match: { customer: config.CUSTOMER_ID }
105
105
  });
106
+ query.deepPopulate([
107
+ 'notes.createdBy'
108
+ ], {
109
+ populate: {
110
+ 'notes.createdBy': { select: 'name avatarUrl title' }
111
+ }
112
+ })
106
113
  query.sort(options.sort);
107
114
 
108
115
  if (options.attendee) { query.where({'attendees.internal': options.attendee}); }
@@ -117,7 +124,7 @@ module.exports = function(mongoose, config) {
117
124
 
118
125
  };
119
126
 
120
- Interaction.statics.getNotes = function getForPeople(personIds, options, cb) {
127
+ Interaction.statics.getNotes = function getNotes(personIds, options, cb) {
121
128
 
122
129
  var self = this;
123
130
  var query = self.find({ totemCustomerId: config.CUSTOMER_ID });
@@ -127,6 +134,13 @@ module.exports = function(mongoose, config) {
127
134
  path: 'notes',
128
135
  match: { customer: config.CUSTOMER_ID }
129
136
  });
137
+ query.deepPopulate([
138
+ 'notes.createdBy'
139
+ ], {
140
+ populate: {
141
+ 'notes.createdBy': { select: 'name avatarUrl title' }
142
+ }
143
+ })
130
144
  query.sort(options.sort);
131
145
  query.exec(cb);
132
146
 
@@ -143,6 +157,9 @@ module.exports = function(mongoose, config) {
143
157
  Interaction.set('autoIndex', true);
144
158
  Interaction.on('index', function(err) { console.log('error building interaction indexes: ' + err); });
145
159
 
160
+ var deepPopulate = require('mongoose-deep-populate')(mongoose);
161
+ Interaction.plugin(deepPopulate);
162
+
146
163
  mongoose.model('Interaction', Interaction);
147
164
 
148
165
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",