Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks
https://atmospherejs.com/matb33/collection-hooks
MIT License
657 stars 92 forks source link

before/after save? #52

Closed ndemoreau closed 10 years ago

ndemoreau commented 10 years ago

Hi,

thanks for the great job!

I just wanted to know if you have plans to include a before/after save hook as well?

mizzao commented 10 years ago

There isn't the concept of save really in Meteor - you could just run the same hook on insert/update if you wanted to. What are you thinking of exactly when you refer to save?

ndemoreau commented 10 years ago

My idea, but I'm new to the world of object db's, is to use it to perform denormalization tasks or any task that should be performed at every object modification (includes insert and updates of course).

In Rails, there is a before/after save callback herefore and It's quite useful

A workaround is indeed to put these maintenance tasks in a function and to call the function from the insert and update callbacks. But it's a workaround. No big deal. Thanks again!

mizzao commented 10 years ago

How do you handle updates with a selector instead of an _id?

I think Meteor is planning to bind objects more tightly to their database representations rather than to just have free-floating Javascript objects in memory. This might be easier to implement when that comes to pass.

ndemoreau commented 10 years ago

OK, thank you!