meteor-collection-behaviours
meteor-collection-behaviours copied to clipboard
Timestampable fails when replacing entire documents
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.
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) :(