@dhyasama/totem-models 8.52.0 → 8.54.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.
- package/lib/LimitedPartner.js +30 -1
- package/package.json +1 -1
package/lib/LimitedPartner.js
CHANGED
|
@@ -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.removeCustomerDetails = function removeCustomerDetails(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: { details: [] } },
|
|
679
|
+
{ multi : true }
|
|
680
|
+
);
|
|
681
|
+
|
|
682
|
+
query.exec(cb);
|
|
683
|
+
|
|
684
|
+
};
|
|
685
|
+
|
|
660
686
|
LimitedPartner.statics.removeCustomerPeople = function removeCustomerPeople(customerId, cb) {
|
|
661
687
|
|
|
662
688
|
const self = this;
|
|
@@ -715,6 +741,9 @@ module.exports = function(mongoose, config) {
|
|
|
715
741
|
lp.entered.by = username;
|
|
716
742
|
lp.entered.on = new Date();
|
|
717
743
|
|
|
744
|
+
// Required for mixed types
|
|
745
|
+
lp.markModified('details');
|
|
746
|
+
|
|
718
747
|
lp.extendWithWriteFilter(lp, options.role);
|
|
719
748
|
lp.save(function(err, result) {
|
|
720
749
|
if (err) return cb(err, null);
|