@dhyasama/totem-models 8.51.0 → 8.53.0

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.
@@ -91,7 +91,15 @@ module.exports = function(mongoose, config) {
91
91
 
92
92
  flags: [ { type: Schema.ObjectId, ref: 'Flag' } ],
93
93
 
94
- notes: [ { type: Schema.ObjectId, ref: 'Note' } ]
94
+ notes: [ { type: Schema.ObjectId, ref: 'Note' } ],
95
+
96
+ // Catch-all for customer specific key-value pairs from sheet that aren't supported by our schema
97
+ details: [{
98
+ key: { type: String, trim: true, required: true },
99
+ value: { type: Schema.Types.Mixed, required: true },
100
+ format: { type: String, enum: [null, 'number', 'decimal', 'money', 'percentage', 'date']},
101
+ _id: false
102
+ }]
95
103
 
96
104
  });
97
105
 
@@ -657,6 +665,24 @@ module.exports = function(mongoose, config) {
657
665
 
658
666
  };
659
667
 
668
+ LimitedPartner.statics.removeCustomerPeople = function removeCustomerPeople(customerId, cb) {
669
+
670
+ const self = this;
671
+
672
+ if (!cb) { throw new Error('cb is required'); }
673
+ if (!customerId) { return cb(new Error('customerId is required'), null); }
674
+ if (!mongoose.Types.ObjectId.isValid(customerId)) { return cb(new Error('customerId is not a valid ObjectId'), null); }
675
+
676
+ let query = self.update(
677
+ { 'customer': customerId },
678
+ { $set: { people: [] } },
679
+ { multi : true }
680
+ );
681
+
682
+ query.exec(cb);
683
+
684
+ };
685
+
660
686
  LimitedPartner.statics.search = function (terms, options, cb) {
661
687
 
662
688
  const self = this;
@@ -697,6 +723,9 @@ module.exports = function(mongoose, config) {
697
723
  lp.entered.by = username;
698
724
  lp.entered.on = new Date();
699
725
 
726
+ // Required for mixed types
727
+ lp.markModified('details');
728
+
700
729
  lp.extendWithWriteFilter(lp, options.role);
701
730
  lp.save(function(err, result) {
702
731
  if (err) return cb(err, null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.51.0",
3
+ "version": "8.53.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",