2.1.0 • Published 3 days ago
mongoose-lean-getters v2.1.0
mongoose-lean-getters
Apply getters on lean() documents: https://mongoosejs.com/docs/tutorials/lean.html
This package requires Mongoose >= 7.1.0
. Do not use with Mongoose 7.0.x or 6.x.
Usage
const mongoose = require('mongoose');
const mongooseLeanGetters = require('mongoose-lean-getters');
const schema = mongoose.Schema({
name: {
type: String,
// Get the last 6 characters of the string
get: v => v.slice(-6)
}
});
// Add this plugin to apply getters when using `lean()`.
schema.plugin(mongooseLeanGetters);
await Model.create({ name: 'Captain Jean-Luc Picard' });
const doc = await Model.findOne().lean({ getters: true });
doc.name; // 'Picard'
2.1.0
3 days ago
2.0.1
2 months ago
2.0.0
2 months ago
1.1.0
11 months ago
1.0.0
1 year ago
0.4.0
1 year ago
0.3.6
1 year ago
0.3.5
2 years ago
0.3.4
2 years ago
0.3.3
2 years ago
0.3.2
2 years ago
0.3.1
2 years ago
0.3.0
2 years ago
0.2.2
2 years ago
0.2.1
3 years ago
0.2.0
3 years ago
0.1.2
4 years ago
0.1.1
5 years ago
0.1.0
5 years ago