Thursday, 27 April 2017

Does mongoose filter out extra properties?

I'm about to work on a new app. And we've decided to use mongo as our db for quick prototyping along with mongoose for an orm. My question is, after declaring a new model. When I try to save a new model will it filter out extra keys? For example. Let's say a model has one property name. Will the model ignore extra keys?

let user = new User({
  name:"bob",
  randomKey: ""
}); 

user.save();

The reason is because I want to be able to do this in an express controller.

let user = new User({ ...req.body});
user.save();

Or in cases where a schema has many props.



via Nate

No comments:

Post a Comment