@dhyasama/totem-models 1.22.0 → 1.22.2

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 (3) hide show
  1. package/.npmignore +14 -0
  2. package/lib/List.js +58 -0
  3. package/package.json +1 -1
package/.npmignore ADDED
@@ -0,0 +1,14 @@
1
+ lib-cov
2
+ *.seed
3
+ *.log
4
+ *.csv
5
+ *.dat
6
+ *.out
7
+ *.pid
8
+ *.gz
9
+
10
+ npm-debug.log
11
+ node_modules
12
+
13
+ .DS_Store
14
+ .idea
package/lib/List.js CHANGED
@@ -122,6 +122,60 @@ 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
+ // DANGER
131
+ // Note this is not filtered by customer!
132
+ // It is used for merging which spans customers
133
+
134
+ self
135
+ .find({ limitedPartners: lpId })
136
+ .populate('limitedPartners', 'name logoUrl')
137
+ .populate('organizations', 'name logoUrl')
138
+ .populate('people', 'name title avatarUrl')
139
+ .exec(cb);
140
+
141
+ };
142
+
143
+ // Get all lists that contain an org
144
+ List.statics.getByOrg = function(orgId, cb) {
145
+
146
+ var self = this;
147
+
148
+ // DANGER
149
+ // Note this is not filtered by customer!
150
+ // It is used for merging which spans customers
151
+
152
+ self
153
+ .find({ organizations: orgId })
154
+ .populate('limitedPartners', 'name logoUrl')
155
+ .populate('organizations', 'name logoUrl')
156
+ .populate('people', 'name title avatarUrl')
157
+ .exec(cb);
158
+
159
+ };
160
+
161
+ // Get all lists that contain a person
162
+ List.statics.getByPerson = function(personId, cb) {
163
+
164
+ var self = this;
165
+
166
+ // DANGER
167
+ // Note this is not filtered by customer!
168
+ // It is used for merging which spans customers
169
+
170
+ self
171
+ .find({ people: personId })
172
+ .populate('limitedPartners', 'name logoUrl')
173
+ .populate('organizations', 'name logoUrl')
174
+ .populate('people', 'name title avatarUrl')
175
+ .exec(cb);
176
+
177
+ };
178
+
125
179
  List.statics.getLists = function(cb) {
126
180
 
127
181
  var self = this;
@@ -156,6 +210,10 @@ module.exports = function(mongoose, config) {
156
210
 
157
211
  };
158
212
 
213
+ List.statics.upsert = function (list, cb) {
214
+ list.save(cb);
215
+ };
216
+
159
217
  List.pre('save', function(next) {
160
218
 
161
219
  var self = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "1.22.0",
3
+ "version": "1.22.2",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",