Unable to add properties to js object

Ah.. My object is a Mongoose document which doesn’t allow adding properties. The solution is to either convert the returned document to a plain object or to call lean() in the query.

Item.findById(req.params.id).exec(function(err, doc) {
  var obj = doc.toObject();
  ...
});

Item.findById(req.params.id).lean().exec(function(err, doc) {      
  ...
});

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)