
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
normalize-mongoose
Advanced tools
Normalize Mongoose JSON output
This plugin removes the following fields _id, __v, and published virtuals id when the document is converted to JSON. Also it allows you to hide private fields like password.
$ npm install normalize-mongoose
Using Github NPM Registry
$ npm install abranhe@normalize-mongoose
import mongoose from 'mongoose';
import normalize from 'normalize-mongoose';
const personSchema = mongoose.Schema({
name: String,
age: Number,
});
personSchema.plugin(normalize);
See how normalize-mongoose will clean the the JSON output:
{
"_id": "5dff03d3218b91425b9d6fab",
"name": "Abraham",
"__v": 0
}
{
"id": "5dff03d3218b91425b9d6fab",
"name": "Abraham"
}
normalize-mongoose comes really handy on real word applications, allowing you to hide from the output any private field previously defined.
import mongoose from 'mongoose';
import normalize from 'normalize-mongoose';
const personSchema = mongoose.Schema({
name: String,
age: Number,
email: String,
password: { type: String, private: true },
});
personSchema.plugin(normalize);
const Person = mongoose.model('Person', personSchema);
const someone = new Person( {
name: 'Abraham',
age: 33,
email: 'abranhe@example.com',
password: 'my_awesome_password',
});
The above code will output:
{
"id": "5dff03d3218b91425b9d6fab",
"name": "Abraham",
"age": 33,
"email": "abranhe@example.com"
}
MIT © Abraham Hernandez
FAQs
Normalize Mongoose JSON output
We found that normalize-mongoose demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.