@dhyasama/totem-models 1.6.3 → 1.7.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/lib/CapTable.js CHANGED
@@ -387,7 +387,7 @@ module.exports = function(mongoose, config) {
387
387
  CapTable.set('toJSON', { virtuals: true });
388
388
  CapTable.set('autoIndex', true);
389
389
 
390
- CapTable.index({ organization: 1, customer: 1 }, { unique: true, sparse: true });
390
+ CapTable.index({ organization: 1, customer: 1 }, { unique: true, partialFilterExpression : { type :"string" } });
391
391
  CapTable.on('index', function(err) { console.log('error building CapTable indexes: ' + err); });
392
392
 
393
393
  mongoose.model('CapTable', CapTable);
package/lib/Investment.js CHANGED
@@ -46,6 +46,20 @@ module.exports = function(mongoose, config) {
46
46
  }
47
47
  },
48
48
 
49
+ converted: { type: Boolean, default: false },
50
+ convertedInto: {
51
+ type: String,
52
+ trim: true,
53
+ validate: {
54
+ validator: function(v) {
55
+ var self = this;
56
+ if (self.converted && (!v || v.length == 0)) return false;
57
+ else return true;
58
+ },
59
+ message: 'The investments is marked as converted but a converted into value was not provided! Either set converted to false or provide a value for converted into.'
60
+ }
61
+ },
62
+
49
63
  // Catch-all for customer specific key-value pairs from sheet that aren't supported by our schema
50
64
  details: [{
51
65
  key: { type: String, trim: true, required: true },
@@ -16,20 +16,20 @@ module.exports = function(mongoose, config) {
16
16
 
17
17
  name: { type: String, required: true, index: true },
18
18
 
19
- slug: { type: String, required: true, unique: true, sparse: false, trim: true, lowercase: true },
19
+ slug: { type: String, required: true, unique: true, trim: true, lowercase: true },
20
20
 
21
21
  logoUrl: { type: String, trim: true },
22
22
 
23
23
  description: { type: String, trim: true },
24
24
 
25
- website: { type: String, unique: true, sparse: true, required: false, trim: true, lowercase: true },
25
+ website: { type: String, unique: true, partialFilterExpression : { type :"string" }, required: false, trim: true, lowercase: true },
26
26
 
27
- websiteAliases: [ { type: String, unique: true, sparse: true, trim: true, lowercase: true } ],
27
+ websiteAliases: [ { type: String, unique: true, partialFilterExpression : { type :"string" }, trim: true, lowercase: true } ],
28
28
 
29
29
  social: {
30
- twitter: { type: String, trim: true, unique: true, sparse: true },
31
- facebook: { type: String, trim: true, unique: true, sparse: true },
32
- linkedin: { type: String, trim: true, unique: true, sparse: true }
30
+ twitter: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
31
+ facebook: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
32
+ linkedin: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } }
33
33
  },
34
34
 
35
35
  contact: {
@@ -68,6 +68,8 @@ module.exports = function(mongoose, config) {
68
68
  board: { type: String, enum: ['chairman', 'director', 'observer', 'none'], default: 'none', index: true }
69
69
  }],
70
70
 
71
+ lps: [{ type: Schema.ObjectId, ref: 'LimitedPartner' }],
72
+
71
73
  entered: {
72
74
  by: { type: String, default: '', trim: true },
73
75
  on: { type: Date, default: Date.now }
@@ -111,8 +113,8 @@ module.exports = function(mongoose, config) {
111
113
  }],
112
114
 
113
115
  crunchbase: {
114
- uuid: { type: String, unique: true, sparse: true, trim: true },
115
- url: { type: String, unique: true, sparse: true, trim: true }
116
+ uuid: { type: String, unique: true, partialFilterExpression : { type : "string" }, trim: true },
117
+ url: { type: String, unique: true, partialFilterExpression : { type :"string" }, trim: true }
116
118
  },
117
119
 
118
120
  related: [{ type: Schema.ObjectId, ref: 'Organization' }],
@@ -124,7 +126,7 @@ module.exports = function(mongoose, config) {
124
126
 
125
127
  active: { type: Boolean, default: false },
126
128
 
127
- totemUrl: { type: String, trim: true, unique: true, sparse: true },
129
+ totemUrl: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
128
130
 
129
131
  style: {
130
132
  backgroundColor: { type: String, default: '#666666', trim: true },
@@ -132,32 +134,32 @@ module.exports = function(mongoose, config) {
132
134
  },
133
135
 
134
136
  investmentsSheet: {
135
- sheet: { type: String, trim: true, unique: true, sparse: true },
137
+ sheet: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
136
138
  googleSheetCreds: {
137
- private_key_id: { type: String, trim: true, unique: true, sparse: true },
138
- private_key: { type: String, trim: true, unique: true, sparse: true },
139
- client_email: { type: String, trim: true, unique: true, sparse: true },
140
- client_id: { type: String, trim: true, unique: true, sparse: true },
139
+ private_key_id: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
140
+ private_key: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
141
+ client_email: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
142
+ client_id: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
141
143
  type: { type: String, trim: true }
142
144
  }
143
145
  },
144
146
 
145
147
  eshares: {
146
- firmid: { type: String, unique: true, sparse: true, trim: true }
148
+ firmid: { type: String, unique: true, partialFilterExpression : { type :"string" }, trim: true }
147
149
  }
148
150
 
149
151
  },
150
152
 
151
153
  docs: [{
152
154
  customer: { type: Schema.ObjectId, ref: 'Organization' },
153
- url: { type: String, trim: true, unique: true, sparse: true }
155
+ url: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } }
154
156
  }],
155
157
 
156
158
  // Link to deeper data on iLevel
157
159
  // iLevelUser must be true at the account level
158
160
  iLevel: [{
159
161
  customer: { type: Schema.ObjectId, ref: 'Organization' },
160
- url: { type: String, trim: true, unique: true, sparse: true }
162
+ url: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } }
161
163
  }],
162
164
 
163
165
  chairs: [{
@@ -505,7 +507,7 @@ module.exports = function(mongoose, config) {
505
507
  var self = this;
506
508
  self
507
509
  .find({ 'funds': { $in : fundids }, 'deleted': {$ne: true} })
508
- .select('name logoUrl')
510
+ .select('name logoUrl funds')
509
511
  .exec(cb);
510
512
  };
511
513
 
@@ -620,7 +622,7 @@ module.exports = function(mongoose, config) {
620
622
  }
621
623
  }
622
624
  })
623
- .select('name avatarUrl')
625
+ .select('name logoUrl people')
624
626
  .exec(cb);
625
627
 
626
628
  };
@@ -1016,7 +1018,7 @@ module.exports = function(mongoose, config) {
1016
1018
  Organization.set('toJSON', { virtuals: true });
1017
1019
  Organization.set('autoIndex', true);
1018
1020
 
1019
- Organization.index({ website: 1, websiteAliases: 1 }, { unique: true, sparse: true });
1021
+ Organization.index({ website: 1, websiteAliases: 1 }, { unique: true, partialFilterExpression : { type :"string" } });
1020
1022
  Organization.on('index', function(err) { console.log('error building organization_new indexes: ' + err); });
1021
1023
 
1022
1024
  var deepPopulate = require('mongoose-deep-populate')(mongoose);
package/lib/Person.js CHANGED
@@ -29,7 +29,7 @@ module.exports = function(mongoose, config) {
29
29
  last: { type: String, default: '', index: true }
30
30
  },
31
31
 
32
- slug: { type: String, required: true, unique: true, sparse: false, trim: true, lowercase: true },
32
+ slug: { type: String, required: true, unique: true, trim: true, lowercase: true },
33
33
 
34
34
  contact: {
35
35
 
@@ -67,15 +67,15 @@ module.exports = function(mongoose, config) {
67
67
  website: { type: String, default: null, required: false, trim: true, lowercase: true },
68
68
 
69
69
  crunchbase: {
70
- uuid: { type: String, unique: true, required: false, sparse: true, trim: true }
70
+ uuid: { type: String, unique: true, required: false, partialFilterExpression : { type :"string" }, trim: true }
71
71
  },
72
72
 
73
73
  vCardUrl: { type: String, default: null, trim: true },
74
74
 
75
75
  social: {
76
- twitter: { type: String, trim: true, unique: true, sparse: true },
77
- facebook: { type: String, trim: true, unique: true, sparse: true },
78
- linkedin: { type: String, trim: true, unique: true, sparse: true }
76
+ twitter: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
77
+ facebook: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } },
78
+ linkedin: { type: String, trim: true, unique: true, partialFilterExpression : { type :"string" } }
79
79
  },
80
80
 
81
81
  avatarUrl: { type: String, default: null, trim: true },
@@ -120,6 +120,9 @@ module.exports = function(mongoose, config) {
120
120
 
121
121
  aliases: [ { type: String, trim: true } ],
122
122
 
123
+ // handy for searching
124
+ fullName: { type: String, index: true, trim: true },
125
+
123
126
  related: [{ type: Schema.ObjectId, ref: 'Person' }],
124
127
 
125
128
  calendarEventSummaries: [
@@ -1032,6 +1035,9 @@ module.exports = function(mongoose, config) {
1032
1035
 
1033
1036
  var self = this;
1034
1037
 
1038
+ // set full name for ease of searching
1039
+ self.fullName = self.name.first + ' ' + self.name.last;
1040
+
1035
1041
  // Reset counters so we can calc from scratch
1036
1042
  _.each(self.sources, function(source) {
1037
1043
  source.interactions.calendar = 0;
package/lib/Round.js CHANGED
@@ -137,6 +137,8 @@ module.exports = function(mongoose, config) {
137
137
  name: rounds[0].organization.name,
138
138
  logoUrl: rounds[0].organization.logoUrl,
139
139
  description: rounds[0].organization.description,
140
+ contact: rounds[0].organization.contact,
141
+ industries: rounds[0].organization.industries,
140
142
  status: rounds[0].organization.status,
141
143
  preMoneyValuation: rounds[0].preMoneyValuation
142
144
  };
@@ -554,7 +556,7 @@ module.exports = function(mongoose, config) {
554
556
  self
555
557
  .find({ 'vehicles.fund': { $in: fundIds } })
556
558
  .select('organization vehicles preMoneyValuation')
557
- .populate('organization', 'name logoUrl description')
559
+ .populate('organization', 'name logoUrl description contact industries')
558
560
  .populate('vehicles.fund')
559
561
  .populate('vehicles.investments')
560
562
  .exec(function(err, rounds) {
@@ -795,7 +797,7 @@ module.exports = function(mongoose, config) {
795
797
  Round.set('toJSON', { virtuals: true });
796
798
  Round.set('autoIndex', true);
797
799
 
798
- Round.index({ organization: 1, roundName: 1 }, { unique: true, sparse: true });
800
+ Round.index({ organization: 1, roundName: 1 }, { unique: true, partialFilterExpression : { type :"string" } });
799
801
  Round.on('index', function(err) { console.log('error building Round indexes: ' + err); });
800
802
 
801
803
  mongoose.model('Round', Round);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "1.6.3",
3
+ "version": "1.7.1",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
package/test/List.js CHANGED
@@ -28,6 +28,15 @@ describe('List', function() {
28
28
  clearDB(done);
29
29
  });
30
30
 
31
+ before(function (done) {
32
+ Person.collection.dropIndexes(function (err, result) {
33
+ should.not.exist(err);
34
+ should.exist(result);
35
+ result.should.equal(true);
36
+ return done();
37
+ });
38
+ });
39
+
31
40
  before(function(done) {
32
41
 
33
42
  lp = new LimitedPartner();
package/test/Person.js CHANGED
@@ -53,6 +53,15 @@ describe('Person', function() {
53
53
  clearDB(done);
54
54
  });
55
55
 
56
+ before(function (done) {
57
+ Person.collection.dropIndexes(function (err, result) {
58
+ should.not.exist(err);
59
+ should.exist(result);
60
+ result.should.equal(true);
61
+ return done();
62
+ });
63
+ });
64
+
56
65
  before(function (done) {
57
66
  LimitedPartner.collection.dropIndexes(function (err, result) {
58
67
  should.not.exist(err);