@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.
Files changed (2) hide show
  1. package/lib/Account.js +6 -6
  2. 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.populated('person')) {
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.populated('person')) {
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.populated('person') && account.populated('org')) {
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.populated('org');
183
+ let customerId = account.org._id;
184
184
 
185
- if (account.populated('org')) { helpers.cleanOrg(account.org, customerId); }
185
+ if (account.org && typeof account.org === 'object') { helpers.cleanOrg(account.org, customerId); }
186
186
 
187
- if (account.populated('person')) { helpers.cleanPerson(account.person, customerId); }
187
+ if (account.person && typeof account.person === 'object') { helpers.cleanPerson(account.person, customerId); }
188
188
 
189
189
  return account;
190
190
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "12.5.0",
3
+ "version": "12.6.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",