@dhyasama/totem-models 1.18.1 → 1.19.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.
@@ -441,6 +441,28 @@ module.exports = function(mongoose, config) {
441
441
 
442
442
  };
443
443
 
444
+ LimitedPartner.statics.getNotes = function getNotes(lpid, cb) {
445
+
446
+ var self = this;
447
+ var query = self.findById(lpid)
448
+
449
+ query.select('notes')
450
+ query.populate({
451
+ path: 'notes',
452
+ match: { customer: config.CUSTOMER_ID }
453
+ })
454
+ query.deepPopulate([
455
+ 'notes.createdBy'
456
+ ], {
457
+ populate: {
458
+ 'notes.createdBy': { select: 'name avatarUrl title' }
459
+ }
460
+ })
461
+ query.sort({'createdOn':-1})
462
+ query.exec(cb);
463
+
464
+ };
465
+
444
466
  LimitedPartner.statics.list = function (role, cb) {
445
467
 
446
468
  // sorted by name ascending
@@ -608,7 +608,6 @@ module.exports = function(mongoose, config) {
608
608
  .find({ '_id': { $in : ids }})
609
609
  .populate('people.person', 'name avatarUrl title calendarEventSummaries sources')
610
610
  .populate('related', 'name logoUrl')
611
- .populate('notes')
612
611
  .populate('chairs.first', 'name avatarUrl title')
613
612
  .populate('chairs.second', 'name avatarUrl title')
614
613
  .populate('funds', 'name hexColorCode')
@@ -616,15 +615,13 @@ module.exports = function(mongoose, config) {
616
615
  'people.person.sources.person',
617
616
  'people.person.calendarEventSummaries.attendees.internal',
618
617
  'people.person.calendarEventSummaries.attendees.external',
619
- 'people.person.calendarEventSummaries.notes.createdBy',
620
- 'notes.createdBy'
618
+ 'people.person.calendarEventSummaries.notes.createdBy'
621
619
  ], {
622
620
  populate: {
623
621
  'people.person.sources.person': { select: 'name avatarUrl title' },
624
622
  'people.person.calendarEventSummaries.attendees.internal': { select: 'name avatarUrl title' },
625
623
  'people.person.calendarEventSummaries.attendees.external': { select: 'name avatarUrl title' },
626
- 'people.person.calendarEventSummaries.notes.createdBy': { select: 'name avatarUrl title' },
627
- 'notes.createdBy': { select: 'name avatarUrl title' }
624
+ 'people.person.calendarEventSummaries.notes.createdBy': { select: 'name avatarUrl title' }
628
625
  }
629
626
  })
630
627
  .exec(cb);
@@ -750,7 +747,6 @@ module.exports = function(mongoose, config) {
750
747
  .findById(id)
751
748
  .populate('people.person', 'name avatarUrl title calendarEventSummaries sources')
752
749
  .populate('related', 'name logoUrl')
753
- .populate('notes')
754
750
  .populate('chairs.first', 'name avatarUrl title')
755
751
  .populate('chairs.second', 'name avatarUrl title')
756
752
  .populate('funds', 'name hexColorCode closeDate')
@@ -761,15 +757,13 @@ module.exports = function(mongoose, config) {
761
757
  'people.person.sources.person',
762
758
  'people.person.calendarEventSummaries.attendees.internal',
763
759
  'people.person.calendarEventSummaries.attendees.external',
764
- 'people.person.calendarEventSummaries.notes.createdBy',
765
- 'notes.createdBy'
760
+ 'people.person.calendarEventSummaries.notes.createdBy'
766
761
  ], {
767
762
  populate: {
768
763
  'people.person.sources.person': { select: 'name avatarUrl title' },
769
764
  'people.person.calendarEventSummaries.attendees.internal': { select: 'name avatarUrl title' },
770
765
  'people.person.calendarEventSummaries.attendees.external': { select: 'name avatarUrl title' },
771
- 'people.person.calendarEventSummaries.notes.createdBy': { select: 'name avatarUrl title' },
772
- 'notes.createdBy': { select: 'name avatarUrl title' }
766
+ 'people.person.calendarEventSummaries.notes.createdBy': { select: 'name avatarUrl title' }
773
767
  }
774
768
  })
775
769
  .exec(cb);
@@ -792,6 +786,28 @@ module.exports = function(mongoose, config) {
792
786
 
793
787
  };
794
788
 
789
+ Organization.statics.getNotes = function getNotes(orgid, cb) {
790
+
791
+ var self = this;
792
+ var query = self.findById(orgid)
793
+
794
+ query.select('notes')
795
+ query.populate({
796
+ path: 'notes',
797
+ match: { customer: config.CUSTOMER_ID }
798
+ })
799
+ query.deepPopulate([
800
+ 'notes.createdBy'
801
+ ], {
802
+ populate: {
803
+ 'notes.createdBy': { select: 'name avatarUrl title' }
804
+ }
805
+ })
806
+ query.sort({'createdOn':-1})
807
+ query.exec(cb);
808
+
809
+ };
810
+
795
811
  Organization.statics.getSources = function(id, cb) {
796
812
 
797
813
  var self = this;
package/lib/Person.js CHANGED
@@ -703,15 +703,12 @@ module.exports = function(mongoose, config) {
703
703
  .populate('calendarEventSummaries.attendees.external', 'avatarUrl name title')
704
704
  .populate('calendarEventSummaries.attendees.internal', 'avatarUrl name title')
705
705
  .populate('calendarEventSummaries.notes')
706
- .populate('notes')
707
706
  .populate('related')
708
707
  .populate('sources.person', 'avatarUrl name title')
709
708
  .deepPopulate([
710
- 'notes.createdBy',
711
709
  'calendarEventSummaries.notes.createdBy'
712
710
  ], {
713
711
  populate: {
714
- 'notes.createdBy': {select: 'avatarUrl name'},
715
712
  'calendarEventSummaries.notes.createdBy': { select: 'avatarUrl name' }
716
713
  }
717
714
  })
@@ -750,6 +747,28 @@ module.exports = function(mongoose, config) {
750
747
  .exec(cb);
751
748
  };
752
749
 
750
+ Person.statics.getNotes = function getNotes(personId, cb) {
751
+
752
+ var self = this;
753
+ var query = self.findById(personId)
754
+
755
+ query.select('notes')
756
+ query.populate({
757
+ path: 'notes',
758
+ match: { customer: config.CUSTOMER_ID }
759
+ })
760
+ query.deepPopulate([
761
+ 'notes.createdBy'
762
+ ], {
763
+ populate: {
764
+ 'notes.createdBy': { select: 'name avatarUrl title' }
765
+ }
766
+ })
767
+ query.sort({'createdOn':-1})
768
+ query.exec(cb);
769
+
770
+ };
771
+
753
772
  // Retrieve any person matching an email in the emails array parameter
754
773
  Person.statics.findByEmails = function (emails, cb) {
755
774
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dhyasama/totem-models",
3
- "version": "1.18.1",
3
+ "version": "1.19.1",
4
4
  "author": "Jason Reynolds",
5
5
  "license": "UNLICENSED",
6
6
  "description": "Models for Totem platform",
@@ -717,26 +717,6 @@ describe('Organization', function() {
717
717
 
718
718
  });
719
719
 
720
- it('gets an org by id with a populated note', function(done) {
721
-
722
- Organization.getById(org4.id, function(err, result) {
723
-
724
- should.not.exist(err);
725
- should.exist(result);
726
- result.notes.length.should.equal(1);
727
- should.exist(result.notes[0].createdBy);
728
- should.exist(result.notes[0].createdBy.avatarUrl);
729
- result.notes[0].createdBy.avatarUrl.length.should.be.above(0);
730
- should.exist(result.notes[0].createdBy.name);
731
- should.exist(result.notes[0].createdBy.name.first);
732
- result.notes[0].createdBy.name.first.length.should.be.above(0);
733
-
734
- return done();
735
-
736
- });
737
-
738
- });
739
-
740
720
  it('deletes a simple note', function(done) {
741
721
 
742
722
  Organization.deleteNote(noteId, function(err, result) {