@dhyasama/totem-models 1.22.0 → 1.22.1
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/.npmignore +14 -0
- package/lib/List.js +46 -0
- package/package.json +1 -1
package/.npmignore
ADDED
package/lib/List.js
CHANGED
|
@@ -122,6 +122,48 @@ module.exports = function(mongoose, config) {
|
|
|
122
122
|
.exec(cb);
|
|
123
123
|
};
|
|
124
124
|
|
|
125
|
+
// Get all lists that contain an lp
|
|
126
|
+
List.statics.getByLP = function(lpId, cb) {
|
|
127
|
+
|
|
128
|
+
var self = this;
|
|
129
|
+
|
|
130
|
+
self
|
|
131
|
+
.find({ 'customer': config.CUSTOMER_ID, limitedPartners: lpId })
|
|
132
|
+
.populate('limitedPartners', 'name logoUrl')
|
|
133
|
+
.populate('organizations', 'name logoUrl')
|
|
134
|
+
.populate('people', 'name title avatarUrl')
|
|
135
|
+
.exec(cb);
|
|
136
|
+
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
// Get all lists that contain an org
|
|
140
|
+
List.statics.getByOrg = function(orgId, cb) {
|
|
141
|
+
|
|
142
|
+
var self = this;
|
|
143
|
+
|
|
144
|
+
self
|
|
145
|
+
.find({ 'customer': config.CUSTOMER_ID, organizations: orgId })
|
|
146
|
+
.populate('limitedPartners', 'name logoUrl')
|
|
147
|
+
.populate('organizations', 'name logoUrl')
|
|
148
|
+
.populate('people', 'name title avatarUrl')
|
|
149
|
+
.exec(cb);
|
|
150
|
+
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// Get all lists that contain a person
|
|
154
|
+
List.statics.getByPerson = function(personId, cb) {
|
|
155
|
+
|
|
156
|
+
var self = this;
|
|
157
|
+
|
|
158
|
+
self
|
|
159
|
+
.find({ 'customer': config.CUSTOMER_ID, people: personId })
|
|
160
|
+
.populate('limitedPartners', 'name logoUrl')
|
|
161
|
+
.populate('organizations', 'name logoUrl')
|
|
162
|
+
.populate('people', 'name title avatarUrl')
|
|
163
|
+
.exec(cb);
|
|
164
|
+
|
|
165
|
+
};
|
|
166
|
+
|
|
125
167
|
List.statics.getLists = function(cb) {
|
|
126
168
|
|
|
127
169
|
var self = this;
|
|
@@ -156,6 +198,10 @@ module.exports = function(mongoose, config) {
|
|
|
156
198
|
|
|
157
199
|
};
|
|
158
200
|
|
|
201
|
+
List.statics.upsert = function (list, cb) {
|
|
202
|
+
list.save(cb);
|
|
203
|
+
};
|
|
204
|
+
|
|
159
205
|
List.pre('save', function(next) {
|
|
160
206
|
|
|
161
207
|
var self = this;
|