const mongoose = require("mongoose")
mongoose.connect("mongodb://localhost/test")
const A = mongoose.model("A", new mongoose.Schema({name: String}))
A.create({name: "aaa"}, (err, doc) => {
console.log(doc) // { _id: 5ae424bdcc21a02b700f9342, name: "aaa", __v: 0 }
doc.toObject = o => 0
console.log(doc) // 0
})
// ------------------------------------
A.create({name: "aaa"}, (err, doc) => {
console.log(doc) // { _id: 5ae42509ae09661d681416f8, name: "aaa", __v: 0 }
doc.toObject = 0
console.log(doc) // : TypeError: this.toObject is not a function
})