Android 如何编写此Firebase规则?

Android 如何编写此Firebase规则?,android,firebase,firebase-realtime-database,firebase-security,Android,Firebase,Firebase Realtime Database,Firebase Security,这是我的数据结构 "Users": { "userId" : { "email" : "xxxx@gmail.com", "points" : 50, "subscriber" : false } } 这是我指定的当前规则 "User":{ "$uid": { ".read": "$uid == auth.uid", ".write": "auth != null" } } 使用该规则^^它允许我写入“User”引用,但我想要的是 "

这是我的数据结构

"Users": {
  "userId" : {
    "email" : "xxxx@gmail.com",
    "points" : 50,
    "subscriber" : false
  }
}
这是我指定的当前规则

"User":{
  "$uid": {
    ".read": "$uid == auth.uid",
    ".write": "auth != null"
   }
}
使用该规则^^它允许我写入
“User”
引用,但我想要的是

"User":{
  "$uid": {
     ".read": "$uid == auth.uid",
     ".write": "$uid == auth.uid"
   }
}
但是这个规则^^不允许我写到
“User”
引用,这意味着我甚至不能创建一个引用,更不用说更新它了

我试着用

"User":{
".write": "auth != null" // << -- this line overrode the entire children
  "$uid": {
    ".read": "$uid == auth.uid",
    ".write": "$uid == auth.uid"
   }
}
“用户”:{
“.write”:“auth!=null”//使用以下命令:

{
  "rules": {
    "users": {
      "$user_id": {
        ".write": "$user_id === auth.uid"
      }
    }
  }

Firebase数据库安全规则中的
===
=
没有区别。@frankvanpoffelen我知道!==和!=是一样的,那么===和==也是一样吗?据我所知,是的。谢谢@josedlujan,我现在就试试谢谢@frankvanpoffelen的编辑。你对大多数与Firebase相关的问题都很有帮助