@dhyasama/totem-models 8.0.5 → 8.0.7
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/Organization.js +24 -10
- package/package.json +1 -1
package/lib/Organization.js
CHANGED
|
@@ -1058,8 +1058,13 @@ module.exports = function(mongoose, config) {
|
|
|
1058
1058
|
if (!cb) { throw new Error('cb is required'); }
|
|
1059
1059
|
if (!domains) { return cb(new Error('domains is required'), null); }
|
|
1060
1060
|
if (!options) { return cb(new Error('options is required'), null); }
|
|
1061
|
-
|
|
1062
|
-
|
|
1061
|
+
|
|
1062
|
+
options = helpers.getDefaultOptions(options);
|
|
1063
|
+
|
|
1064
|
+
if (!options.isWorkerProcess) {
|
|
1065
|
+
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
1066
|
+
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
1067
|
+
}
|
|
1063
1068
|
|
|
1064
1069
|
// we haven't been able to avoid some domains having a protocol prefix in the database
|
|
1065
1070
|
// until we can, use protocol as part of searching by domain
|
|
@@ -1091,9 +1096,11 @@ module.exports = function(mongoose, config) {
|
|
|
1091
1096
|
if (err) { return cb(err, null); }
|
|
1092
1097
|
else if (!orgs) { return cb(null, []); }
|
|
1093
1098
|
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1099
|
+
if (!options.isWorkerProcess) {
|
|
1100
|
+
orgs = _.map(orgs, function(org) {
|
|
1101
|
+
return helpers.cleanOrg(org, options.CUSTOMER_ID);
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1097
1104
|
|
|
1098
1105
|
return cb(null, orgs);
|
|
1099
1106
|
|
|
@@ -1116,8 +1123,13 @@ module.exports = function(mongoose, config) {
|
|
|
1116
1123
|
if (!cb) { throw new Error('cb is required'); }
|
|
1117
1124
|
if (!ids) { return cb(new Error('ids is required'), null); }
|
|
1118
1125
|
if (!options) { return cb(new Error('options is required'), null); }
|
|
1119
|
-
|
|
1120
|
-
|
|
1126
|
+
|
|
1127
|
+
options = helpers.getDefaultOptions(options);
|
|
1128
|
+
|
|
1129
|
+
if (!options.isWorkerProcess) {
|
|
1130
|
+
if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
|
|
1131
|
+
if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
|
|
1132
|
+
}
|
|
1121
1133
|
|
|
1122
1134
|
self
|
|
1123
1135
|
.find({ '_id': { $in : ids }})
|
|
@@ -1126,9 +1138,11 @@ module.exports = function(mongoose, config) {
|
|
|
1126
1138
|
if (err) { return cb(err, null); }
|
|
1127
1139
|
else if (!orgs) { return cb(null, []); }
|
|
1128
1140
|
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1141
|
+
if (!options.isWorkerProcess) {
|
|
1142
|
+
orgs = _.map(orgs, function(org) {
|
|
1143
|
+
return helpers.cleanOrg(org, options.CUSTOMER_ID);
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1132
1146
|
|
|
1133
1147
|
return cb(null, orgs);
|
|
1134
1148
|
|