Skip to content

Latest commit

 

History

History
29 lines (21 loc) · 701 Bytes

README.md

File metadata and controls

29 lines (21 loc) · 701 Bytes

mongoose-hide

Plugin hides fields when user calls document.toJSON(). By default it automatically hides fields _id, __v, createdAt, updatedAt and adds virtual property id

Build Status

Usage

Requires nodejs >= 6.0

const mongohide = require('mongoose-hide');

const schema = new mongoose.Schema({
  visibleField: String,
  hiddenField: {
    type: String,
    hidden: true
  }
});

schema.plugin(mongohide);

to disable hiding some of autohidden fields call plugin with options:

schema.plugin(mongohide, {createdAt: false});