var mongoose = require('mongoose'); mongoose.Types.ObjectId.prototype.toProtobuf = function () { return new Buffer(this.id,'binary'); }