@dhyasama/totem-models 6.16.0 → 6.16.1
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 +9 -11
- package/package.json +1 -1
package/lib/Organization.js
CHANGED
|
@@ -1818,20 +1818,18 @@ module.exports = function(mongoose, config) {
|
|
|
1818
1818
|
this.collection.stats(cb);
|
|
1819
1819
|
};
|
|
1820
1820
|
|
|
1821
|
-
|
|
1821
|
+
Organization.statics.upsert = function(org, username, cb) {
|
|
1822
1822
|
|
|
1823
|
-
if (!
|
|
1824
|
-
if (!username) { return cb(new Error('
|
|
1823
|
+
if (!org) { return cb(new Error('Organization is required'), null); }
|
|
1824
|
+
if (!username) { return cb(new Error('Username is required'), null); }
|
|
1825
1825
|
|
|
1826
|
-
|
|
1827
|
-
|
|
1826
|
+
org.entered.by = username;
|
|
1827
|
+
org.entered.on = new Date();
|
|
1828
1828
|
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
return cb(null, result);
|
|
1834
|
-
});
|
|
1829
|
+
// Clean up missing references
|
|
1830
|
+
org.people = _.reject(org.people, function(item) { return !item.person; });
|
|
1831
|
+
|
|
1832
|
+
org.save(cb);
|
|
1835
1833
|
|
|
1836
1834
|
};
|
|
1837
1835
|
|