Working with a toy example, lets say I have the following Schema:
const ExampleSchema = new mongoose.Schema({
publicField: String,
privateField: { type: String, select: false }
});
ExampleSchema.methods.doSomething = async function() {
console.log(this.privateField); // undefined
}
How do I access the privateField
in the doSomething
function?
Or is there a better to achieve this?