Mongoose. Remove fields on save that are not present in schema
I have a doc saved in MongoDB like this:
{
title: 'title',
author: 'author name',
body: 'the body',
admin: 'admin user'
}
And this is the schema in Mongoose:
var blogSchema = new Schema({
title: String,
author: String,
body: String
});
I would like that on save, the "admin" field was removed from the doc, is this possible? Can I automatize this in event pre-save?
Thanks.
0 comments:
Post a Comment
Thanks