Open raq929 opened 7 years ago
This is on the solution branch. @payne-chris-r sez:
const update = function(id, field, value) { let modify = {}; modify[field] = value; Person.findById(id).then(function(person) { person[field] = value; return person.save(); }).then(function(person) { console.log(person.toJSON()); }).catch(console.error).then(done); };
The o.O is about the two modify lines at the top of the function. It will throw an error if field is undefined. The modify object is not used. If anything, this should be an if(field), but I don't think even that is needed. (Says me.)
if(field)
I believe this is cruft from using findByIdAndUpdagte.
findByIdAndUpdagte
If modify isn't used, then those two lines should be deleted.
modify
This is on the solution branch. @payne-chris-r sez:
The o.O is about the two modify lines at the top of the function. It will throw an error if field is undefined. The modify object is not used. If anything, this should be an
if(field)
, but I don't think even that is needed. (Says me.)