In Your users object there will be users like this
users : {
user1234abc:{
name: "abc"
},
user2434dbcc:{
name: "abc"
}
}
you will have many unique key/user nodes
in users object, eg user1234abc
, user2434dbcc
That unique key can be named any variable
in rules it not necessary to call it $user_id
, you can call it anything you want for example you can name the variable as $any_variable
for unique user keys
and in auth.id whenever user successfully authenticate that same unique id is in auth.uid
so you can any where math that auth.uid
when you are editing the info related to that user
For example if auth.uid
contains user1234abc
and if user1234abc
is editing this object user1234abc:{name: "abc" }
thn accordind to .write rule he will be able to
See the updated view below
Updated Visual Hierarchy:
--schema--
users : {
________________
|
user1234abc:{ |
name: "abc" |
}, |
user2434dbcc:{ |
name: "abc" |
} |
} key can be name as any variable in rules
|
-- rules--
|
{ |
"rules": { |
"users": { |
".read": true, |
________________|___________
| |
\|/ |
"$any_variable": { \|/
".write": "$any_variable === auth.uid"
}
}
}
}