@dhyasama/totem-models 10.56.1 → 10.57.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/Financials.js +22 -0
  2. package/package.json +1 -1
package/lib/Financials.js CHANGED
@@ -349,6 +349,28 @@ module.exports = function(mongoose, config) {
349
349
 
350
350
  };
351
351
 
352
+ Financials.statics.getDocument = function getDocument(documentId, cb) {
353
+
354
+ if (!cb) { throw new Error('cb is required'); }
355
+ if (!documentId) { return cb(new Error('documentId is required'), null); }
356
+ if (!mongoose.Types.ObjectId.isValid(documentId)) { return cb(new Error('documentId is not a valid ObjectId'), null); }
357
+
358
+ const self = this;
359
+
360
+ self.aggregate([
361
+ { $unwind: '$snapshots' },
362
+ { $unwind: '$snapshots.documents' },
363
+ { $match: { 'snapshots.documents.document': documentId } },
364
+ {
365
+ $project: {
366
+ uuid: '$snapshots.uuid',
367
+ document: '$snapshots.documents'
368
+ }
369
+ }
370
+ ]).exec(cb);
371
+
372
+ };
373
+
352
374
  Financials.statics.getRecurringToSend = function getRecurringToSend(options, cb) {
353
375
 
354
376
  const self = this;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "10.56.1",
3
+ "version": "10.57.1",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",