Well presuming that you have something that has you "filedata" in a variable, and of course the user _id that you are updating, then you wan't the $set
operator:
var user = { /* The user information, at least the _id */
var filedata = { /* From somewhere with _id, name, size, type */ };
models.User.findOneAndUpdate(
{ "_id": user._id, "files._id": filedata._id },
{
"$set": {
"name": filedata.name,
"size": filedata.size,
"type": filedata.type
}
},
function(err,user) {
// Whatever in here such a message, but the update is already done.
}
);
Or really, just only $set
the fields that you actually mean to "update" as long as you know which ones you mean. So if you only need to change the "size" then just set that for example.