I’m inserting documents using node mongodb native driver into a mongodb (sic!). My objects look like this:
var x = {
field: 'value',
_nonPersistentField: 'Do not save that'
};
What I want to achieve is, to prevent all fields prefixed with an underscore not to be saved. In the example above ‘_nonPersistentField’ should not be saved.
Is there a way (except Object.defineProperty) to prevent these fields from being saved in node mongodb native?
What about a pre-parser? Instead of using
savefrom the mongo client, use:Using this way, you’re not even seeing the object creation and whatnot, instead of:
You’re using: