Open DesignByOnyx opened 4 months ago
Summary
This allows setting { getters: true } at a plugin level. This can be overridden at call time to disable getters if need be. Closes #33.
{ getters: true }
Examples
const testSchema = new mongoose.Schema({ field: { type: String, get(val) { return `${val}-suffix`; }, } }); testSchema.plugin(mongooseLeanGetters, { defaultLeanOptions: { getters: true } }); const TestModel = mongoose.model('gh-33', testSchema); const entry = await TestModel.create({ field: 'value' }); const doc1 = await TestModel.findById(entry._id).lean(); assert.equal(doc1.field, 'value-suffix'); const doc2 = await TestModel.findById(entry._id).lean({ getters: false }); assert.equal(doc2.field, 'value');
Hi,
I'm very interested by such feature. Any clue when it would release?
Summary
This allows setting
{ getters: true }
at a plugin level. This can be overridden at call time to disable getters if need be. Closes #33.Examples