@dhyasama/totem-models 8.75.0 → 8.75.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.
Files changed (2) hide show
  1. package/lib/CapTable.js +28 -0
  2. package/package.json +1 -1
package/lib/CapTable.js CHANGED
@@ -18,6 +18,7 @@ module.exports = function(mongoose, config) {
18
18
  var Organization = mongoose.model('Organization');
19
19
  var _ = require('underscore');
20
20
  var async = require('async');
21
+ var helpers = require('../helpers');
21
22
 
22
23
  var CapTable = new Schema({
23
24
 
@@ -340,6 +341,33 @@ module.exports = function(mongoose, config) {
340
341
 
341
342
  };
342
343
 
344
+ CapTable.statics.search = function (terms, options, cb) {
345
+
346
+ const self = this;
347
+
348
+ if (!cb) { throw new Error('cb is required'); }
349
+ if (!terms) { return cb(new Error('terms is required'), null); }
350
+ if (!options) { return cb(new Error('options is required'), null); }
351
+ if (!options.CUSTOMER_ID) { return cb(new Error('options.CUSTOMER_ID is required'), null); }
352
+ if (!mongoose.Types.ObjectId.isValid(options.CUSTOMER_ID)) { return cb(new Error('options.CUSTOMER_ID is not a valid ObjectId'), null); }
353
+
354
+ options = helpers.getDefaultOptions(options);
355
+
356
+ let query;
357
+
358
+ query = self.find({
359
+ customer: options.CUSTOMER_ID,
360
+ 'stakeholders.name': new RegExp(terms, 'i'),
361
+ 'stakeholders.person': null,
362
+ 'stakeholders.fund': null
363
+ });
364
+
365
+ query.populate('organization', 'name logoUrl');
366
+ query.sort({ 'name': -1 });
367
+ query.exec(cb);
368
+
369
+ };
370
+
343
371
  CapTable.statics.updateOriginalDocumentUrl = function updateOriginalDocumentUrl(id, originalDocumentUrl, cb) {
344
372
 
345
373
  var self = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "8.75.0",
3
+ "version": "8.75.1",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",