mblarsen / mongoose-hidden

A Mongoose schema plugin for filtering properties you usually do not want to sent client-side like passwords and IDs.
MIT License
89 stars 19 forks source link

missing fields defined as {} #101

Open AlbertHambardzumyan opened 2 years ago

AlbertHambardzumyan commented 2 years ago

Hi

Given the following schema

const mongoose = require('mongoose')
const mongooseHidden = require('mongoose-hidden')()

const SomeSchema = new mongoose.Schema({
  field: { type: String, maxlength: 255 },
  meta: {
    data: {}
  }
}, { timestamps: true, minimize: false })

SomeSchema.plugin(mongooseHidden, { defaultHidden: { __v: true } })

I'm losing meta field entirely, as I do findOne. I'm not sure whether I'm misusing the plugin or thats a bug.

mongoose: 5.12.5 mongoose-hidden: 1.6.1

mblarsen commented 2 years ago

Could you create a test case here: https://github.com/mblarsen/mongoose-hidden/blob/master/test/github-issues.js?