meteor-collection-behaviours icon indicating copy to clipboard operation
meteor-collection-behaviours copied to clipboard

Timestampable fails when replacing entire documents

Open svub opened this issue 11 years ago • 1 comments

Updating an entire document via "collection.update(id, document)" fails: Exception while simulating the effect of invoking '/activities/update' Error {} Error: When replacing document, field name may not start with '$' as the document gets extended by "$set: { updatedAt: 1384867681991 }". Timestampable will need to handle this case separately... I'll submit a pull request soon.

svub avatar Nov 19 '13 13:11 svub

Thought it to be an easy fix like this:

self.before.update(function (userId, doc, fieldNames, modifier, options) {
  if(!modifier.$set) doc.updatedAt = Date.now();
  else modifier.$set.updatedAt = Date.now();
});

But meteor-collection-hooks ignores the modified doc. (cf. "update.js" of meteor-collection-hooks) :(

svub avatar Nov 19 '13 14:11 svub