There really is no difference and that's just us being inconsistent in naming. You could call it $foobarbaz and it would still act the same way. It is simply a Firebase Rules $ variable used as a catchall key name.
What is this referring to?
Kato was referring to the $ variable as this. Since the $ variable is just a key catchall key name, it act likes any other key in your Firebase Rules. That means it can have children nodes.
$message_id and $message were declared as siblings in my example so this is confusing to me.
This is confusing to me as well and I don't think your initial rules are what you want. You should go for something along these lines:
{
"messages": {
"$messageId": {
"creator": {
// .read, .write, .validate rules for creator
},
"content": {
// .read, .write, .validate rules for content
},
"timestamp": {
// .read, .write, .validate rules for timestamp
},
}
}
}
You have a /messages/ node which can have any number of message underneath it, as represented by the $messageId variable. The ID of each message will be stored in that variable and is accessible in any descendant's rules. Then, underneath each message, we add rules for different required items (in this case, I just chose a few random items).
I hope my explanations above answer your other questions / comments as well. If you have not already, I would strongly reading through
our entire Security guide for a full walkthrough of how this works.
Jacob