Created
August 1, 2017 12:02
-
-
Save Pokom/3bf3122b53d6ccef7dea1db0650f8354 to your computer and use it in GitHub Desktop.
Example of a virtual on a mongoose object
This file contains hidden or 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
AssetsSchema.virtual('test').get(function () { | |
return Object.keys(this.licenseNode).reduce(({ prev, key }) => { | |
if (typeof this.licenseNode[key] === Number && this.licenseNode[key] > 0) { | |
prev[key] = this.licenseNode[key]; | |
} | |
return prev; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment