Created
February 12, 2016 19:11
-
-
Save rturk/f5ff8a16124365b8a113 to your computer and use it in GitHub Desktop.
Mongoose Virtual field async await
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Schema.virtual('comments') | |
//Returns comment owned by this product | |
.get( | |
async obj => await Comment | |
.find({ 'owner': this._id, deleted: { $ne: true } }) | |
.sort('-likesCount -date_modified') | |
.limit(6) | |
.exec() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing! Just what I need.