Meteor-Community-Packages / meteor-collection-hooks

Meteor Collection Hooks

Home Page:https://atmospherejs.com/matb33/collection-hooks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

before.update doc is old doc before updates? Or is doc the new doc as will be saved?

opened this issue · comments

I'd like to validate doc on before.update, but apparently doc is the old doc before the modifier is applied to it. How do we validate the new doc?

Answer: use LocalCollection from minimongo:

LocalCollection._modify(doc, modifier)

That modifies the doc in place, and then we can perform checks on it's new modified state.