Skip to content

Instantly share code, notes, and snippets.

View yamadapc's full-sized avatar
🎼

Pedro Tacla Yamada yamadapc

🎼
View GitHub Profile
var mongoose = require('mongoose');
var native = mongoose.Document.prototype.toObject;
module.exports = function(schema/* options [could make it safer :)]*/) {
schema.methods.toObject = function() {
var _this = this;
var obj = mongoose.Document.prototype.toObject.apply(this, arguments);
var extraneous = Object.keys(this).filter(function(key) {