@dhyasama/totem-models 2.1.2 → 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.
- package/lib/Interaction.js +18 -1
- package/package.json +1 -1
package/lib/Interaction.js
CHANGED
|
@@ -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
|
|
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
|
};
|