Created
April 15, 2015 17:12
-
-
Save alesanabriav/f3ff9038d000c35ee660 to your computer and use it in GitHub Desktop.
change _id to id on mongoose model
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
schemaName.set('toJSON', { | |
transform: function (doc, ret, options) { | |
ret.id = ret._id; | |
delete ret._id; | |
delete ret.__v; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment