New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-whitelist

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-whitelist

Tiny plugin to simplify whitelisting

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source
Sample Usage

Setup the plugin

const mongoose = require('mongoose')
const whitelist = require('mongoose-whitelist')

const UserSchema = new mongoose.Schema({
   name: {
      first: { type: String },
      last: { type: String }
   },
   email: { type: String },
   encrypted_password: { type: String }
})

UserSchema.plugin(whitelist, {
   attributes: ['name', 'email']
})

mongoose.model('user', UserSchema)

Applying the plugin

const User = mongoose.model('user')
const user = new User()

const payload = {
   'name.first': 'John',
   'name.last': 'McGee',
   email: 'john@test.co',
   encrypted_password: 'terrible-password'
}

// Only set whitelisted properties
// (encrypted_password will not be set)
user.set(User.whitelist(payload))
License

MIT. Copyright (c) 2016 Mother Co.

Keywords

FAQs

Package last updated on 15 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc