Not hiding fields
rhyek opened this issue · comments
Carlos González commented
Is there anything wrong with this configuration?
import mongoose from 'mongoose'
import hidden from 'mongoose-hidden'
const schema = new mongoose.Schema({
email: {
type: String,
unique: true,
},
hashedPassword: {
type: String,
hide: true,
},
firstName: String,
lastName: String,
profilePicture: Object,
isAdmin: Boolean,
organizations: [{ type: mongoose.Schema.ObjectId, ref: 'Organization' }],
})
schema.plugin(hidden)
export default mongoose.model('User', schema)
Neither toJSON
nor toObject
are actually hiding hashedPassword
.
Using mongodb 3.0.2, mongoose 5.0.6, mongoose-hidden 1.5.3.
Michael Bøcker-Larsen commented
Try
schema.plugin(hidden())
The plugin import is a function. Let me know if that helps.
Carlos González commented
Yup, that works. Missed those parenthesis in the examples :).