1
次のfirebaseデータベースルールを考慮してください。子供(友達)を一つずつ削除できるルールを書く方法があるのだろうか?子供を1人ずつ削除できるようにするFirebaseルール
ここでは、友だちが空であるか子供がいる必要があるため、単純な削除操作は機能しません。ただし、他の子を持つように更新することができます。つまり、すべての子を一度に上書きすることができます。
"user":
{
"$uid":
{
/* user can read all user data */
".read": "$uid == auth.uid",
/* allow to add to friends but not delete */
".write": "$uid == auth.uid && (!data.child('friends').exists() || newData.child('friends').hasChildren())",
/* other user data also needs to be writable */
"name": {},
/* only explicit user data is allowed */
"$other": { ".validate": false },
"friends":
{
"$friend_uid": { ".validate": "root.child('user').child($friend_uid).exists()" },
},
}
}