vendredi 8 avril 2016

Mongoose: Disallow modification of specific schema field?

There are some fields, such as object ID, or timeCreated, which I want to keep its default value and does not allow it to be overwritten by POST or PUT requests. For example, the timeCreated could possibly be defined in Schema as
timeCreated: {type: Date, default: Date.now}

and I don't want this field to be modified by POST and PUT requests, that is, the timeCreated key in the request body will be ignored. Any idea how to achieve this?




Aucun commentaire:

Enregistrer un commentaire