Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestampable fails when replacing entire documents #3

Open
svub opened this issue Nov 19, 2013 · 1 comment
Open

Timestampable fails when replacing entire documents #3

svub opened this issue Nov 19, 2013 · 1 comment

Comments

@svub
Copy link
Contributor

svub commented Nov 19, 2013

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
Copy link
Contributor Author

svub commented Nov 19, 2013

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)
:(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant