@dhyasama/totem-models 9.63.0 → 9.64.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.
|
@@ -15,9 +15,6 @@ module.exports = function(mongoose, config) {
|
|
|
15
15
|
// date and time to send
|
|
16
16
|
sendOn: { type: Date, required: true },
|
|
17
17
|
|
|
18
|
-
// whether the task has been sent to the queue
|
|
19
|
-
sentToQueue: { type: Boolean, default: false },
|
|
20
|
-
|
|
21
18
|
// email content
|
|
22
19
|
email: {
|
|
23
20
|
|
|
@@ -29,6 +26,9 @@ module.exports = function(mongoose, config) {
|
|
|
29
26
|
|
|
30
27
|
},
|
|
31
28
|
|
|
29
|
+
// whether the task has been sent to the queue
|
|
30
|
+
sentToQueue: { type: Boolean, default: false },
|
|
31
|
+
|
|
32
32
|
limitedPartners: [{
|
|
33
33
|
|
|
34
34
|
// the lp it's for
|
|
@@ -80,7 +80,7 @@ module.exports = function(mongoose, config) {
|
|
|
80
80
|
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
81
81
|
|
|
82
82
|
let query = self.find({
|
|
83
|
-
limitedPartner: lpid,
|
|
83
|
+
limitedPartners.limitedPartner: lpid,
|
|
84
84
|
customer: options.CUSTOMER_ID
|
|
85
85
|
});
|
|
86
86
|
|
|
@@ -142,6 +142,37 @@ module.exports = function(mongoose, config) {
|
|
|
142
142
|
|
|
143
143
|
};
|
|
144
144
|
|
|
145
|
+
LimitedPartnerCommunication.statics.delete = function(id, options, cb) {
|
|
146
|
+
|
|
147
|
+
let self = this;
|
|
148
|
+
|
|
149
|
+
if (!cb) { throw new Error('cb is required'); }
|
|
150
|
+
if (!id) { return cb(new Error('id is required'), null); }
|
|
151
|
+
if (!mongoose.Types.ObjectId.isValid(id)) { return cb(new Error('id is not a valid ObjectId'), null); }
|
|
152
|
+
if (!options) { return cb(new Error('options is required'), null); }
|
|
153
|
+
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
154
|
+
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
155
|
+
|
|
156
|
+
// Not strictly necessary but provides verification that the document being deleted belongs to the customer doing the deleting
|
|
157
|
+
|
|
158
|
+
let query = self.findOne({
|
|
159
|
+
'_id': id,
|
|
160
|
+
'customer': options.CUSTOMER_ID
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
query.exec(function(err, doc) {
|
|
164
|
+
|
|
165
|
+
if (err) return cb(err, null);
|
|
166
|
+
else if (!doc) return cb(null, null);
|
|
167
|
+
|
|
168
|
+
// No population so no need to scrub
|
|
169
|
+
|
|
170
|
+
doc.remove(cb);
|
|
171
|
+
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
};
|
|
175
|
+
|
|
145
176
|
LimitedPartnerCommunication.statics.upsert = function upsert(doc, options, cb) {
|
|
146
177
|
|
|
147
178
|
if (!doc) { return cb(new Error('doc is required'), null); }
|