@dhyasama/totem-models 12.5.0 → 12.6.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/Account.js +6 -6
- package/package.json +1 -1
package/lib/Account.js
CHANGED
|
@@ -110,7 +110,7 @@ module.exports = function(mongoose, config) {
|
|
|
110
110
|
const account = await this.findOne(query).populate('person').lean({ virtuals: true });
|
|
111
111
|
if (!account) { return null; }
|
|
112
112
|
|
|
113
|
-
if (account.
|
|
113
|
+
if (account.person && typeof account.person === 'object') {
|
|
114
114
|
|
|
115
115
|
if (account.org) { helpers.cleanPerson(account.person, account.org); }
|
|
116
116
|
else { account.person.sources = []; }
|
|
@@ -147,7 +147,7 @@ module.exports = function(mongoose, config) {
|
|
|
147
147
|
|
|
148
148
|
_.each(accounts, function(account) {
|
|
149
149
|
|
|
150
|
-
if (account.
|
|
150
|
+
if (account.person && typeof account.person === 'object') {
|
|
151
151
|
|
|
152
152
|
if (account.org) { helpers.cleanPerson(account.person, account.org); }
|
|
153
153
|
else { account.person.sources = []; }
|
|
@@ -176,15 +176,15 @@ module.exports = function(mongoose, config) {
|
|
|
176
176
|
query.populate('org');
|
|
177
177
|
|
|
178
178
|
const account = await query.lean({ virtuals: true });
|
|
179
|
-
if (account && account.
|
|
179
|
+
if (account && account.person && typeof account.person === 'object' && account.org && typeof account.org === 'object') {
|
|
180
180
|
|
|
181
181
|
// Scrub customer info before returning
|
|
182
182
|
|
|
183
|
-
let customerId = account.
|
|
183
|
+
let customerId = account.org._id;
|
|
184
184
|
|
|
185
|
-
if (account.
|
|
185
|
+
if (account.org && typeof account.org === 'object') { helpers.cleanOrg(account.org, customerId); }
|
|
186
186
|
|
|
187
|
-
if (account.
|
|
187
|
+
if (account.person && typeof account.person === 'object') { helpers.cleanPerson(account.person, customerId); }
|
|
188
188
|
|
|
189
189
|
return account;
|
|
190
190
|
|