@dhyasama/totem-models 5.10.4 → 5.10.6
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/Deal.js +16 -1
- package/package.json +1 -1
package/lib/Deal.js
CHANGED
|
@@ -95,6 +95,21 @@ module.exports = function(mongoose, config) {
|
|
|
95
95
|
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
+
Deal.virtual('voteValue').get(function () {
|
|
99
|
+
|
|
100
|
+
var self = this;
|
|
101
|
+
|
|
102
|
+
if(!self.votes || self.votes.length == 0) return null;
|
|
103
|
+
|
|
104
|
+
var voteValue = 0;
|
|
105
|
+
_.each(self.votes, function(vote) {
|
|
106
|
+
voteValue += vote.value;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return voteValue;
|
|
110
|
+
|
|
111
|
+
});
|
|
112
|
+
|
|
98
113
|
///////////////////////////////////////////////////////////////////////////////////////
|
|
99
114
|
// METHODS
|
|
100
115
|
// Methods operate on a single document that has already been returned
|
|
@@ -172,7 +187,7 @@ module.exports = function(mongoose, config) {
|
|
|
172
187
|
.populate('messages')
|
|
173
188
|
.populate('sources.person', 'name avatarUrl title')
|
|
174
189
|
.populate('referrers.person', 'name avatarUrl title')
|
|
175
|
-
.populate('votes.
|
|
190
|
+
.populate('votes.person', 'name avatarUrl title')
|
|
176
191
|
.populate({
|
|
177
192
|
path: 'documents',
|
|
178
193
|
match: { customer: customerId }
|