@dhyasama/totem-models 8.56.0 → 8.57.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 +32 -0
  2. package/package.json +1 -1
package/lib/Account.js CHANGED
@@ -120,6 +120,38 @@ module.exports = function(mongoose, config) {
120
120
  });
121
121
  };
122
122
 
123
+ Account.statics.findByEmails = function(emails, cb) {
124
+
125
+ let self = this;
126
+
127
+ if (!cb) { throw new Error('cb is required'); }
128
+ if (!emails) { return cb(new Error('email is required'), null); }
129
+
130
+ self
131
+ .find({ 'email': { $in : emails }})
132
+ .populate('person')
133
+ .exec(function(err, accounts) {
134
+
135
+ if (err) { return cb(err); }
136
+ else if (!accounts) { return cb(null, null); }
137
+
138
+ _.each(accounts, function(account) {
139
+
140
+ if (account.populated('person')) {
141
+
142
+ if (account.org) { helpers.cleanPerson(account.person, account.org); }
143
+ else { account.person.sources = []; }
144
+
145
+ }
146
+
147
+ });
148
+
149
+ return cb(null, accounts);
150
+
151
+ });
152
+
153
+ };
154
+
123
155
  Account.statics.getById = function (id, cb) {
124
156
 
125
157
  const self = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.56.0",
3
+ "version": "8.57.0",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",