javascript - See the updated document in allow / deny rule in Meteor.js -
i'd specify allow rule document update in meteor.js depend on properties of updated document. in update
callback, old document, list of changed top-level fields , mongo modifier. there easy way determine how document if updated?
a non-trivial real-life example: i've got party
model maxcount
integer specifies how many people can fit in party, , people
array names of people attending. user can push several names array. i'd allow update made if in resulting document length of array not exceed maxcount
.
this perfect example of why allow/deny rules in current form insufficient real world problems. there multitude of ways document can updated, , it's impractical check of them tools allow/deny gives you. i'd should use them if permissions like: "the owner of document can whatever wants document".
that being said, if really want example above try checking if people.length < maxcount
when modifier['$push']['people']
defined.
as far know, general solution problem not exist. why use methods db mutations.
you can have @ simple-schema , collection2 (i haven't tried them). according docs, simple-schema can take function when defining min/max
on field. i'm unclear if means can dynamically define min/max
based on object being updated or not.
Comments
Post a Comment