I am creating an reddit-type app. I have an array of stories, and each story has a title, description, and a voteCount. I want to have separate .write rules for the voteCount, so I structured my rules like this -
"stories": {
"$story_id": {
"title": { ".write": "auth !== null" },
"description" { ".write": "auth !== null" },
"voteCount": { ".write": "newData.val() === data.val() + 1" },
}
}
This works for existing stories.However, this no longer allows me to add a new story, unless I add the .write rule directly to the $story_id node. And of course this stops me from having the special .write rule for the voteCount node.
Any ideas on why this happens?