Mongoose plugin to replace _id by id and remove __v, __t when toJSON is called on a mongoose document
npm install mongoose-sanitize-json
This plugin removes the following fields "_id, __v, __t" and published virtuals "id" when the document is converted to json.
(Note other virtual fields will also be published)
``sh`
$ npm install mongoose-sanitize-json
`javascript
var mongoose = require('mongoose');
var sanitizeJSON = require('mongoose-sanitize-json');
var personSchema = mongoose.Schema({
name: String,
age: Number
});
personSchema.plugin(sanitizeJSON);
``