
Security News
TypeScript is Porting Its Compiler to Go for 10x Faster Builds
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
mongoose-hidden
Advanced tools
A Mongoose schema plugin that hooks into toJSON
and toObject
to allow filtering of properties you usually do not want to sent client-side.
npm install mongoose-hidden
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
mongooseHidden = require('mongoose-hidden');
var UserSchema = new Schema(
name: String,
password: { type: String, hide: true },
email: String
);
UserSchema.plugin(mongooseHidden);
var User = mongoose.model('User', UserSchema);
var user = new User({ name: "Joe", email: "joe@example.com", password: "secret" });
user.save(function() {
var jsonUser = user.toJSON();
console.log(jsonUser);
// Outputs: { name: "Joe", email: "joe@example.com" }
});
In stead of hide: true
you can specify the property to only be hiden for toJSON
or toObject
be writing: hideJSON: true
or hideObject
respectivly.
Implement turning on and off on a single invocation (if possible). Something like this:
var jsonUser = user.toJSON({ hide: false });
FAQs
Did you know?
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.
Security News
TypeScript is porting its compiler to Go, delivering 10x faster builds, lower memory usage, and improved editor performance for a smoother developer experience.
Research
Security News
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.