★前回の記事
データベースルールファイルを変更します。
todosのルール
STEP 3では他のユーザのタスクは見れるので、そのように変更します。
database.rules.json
{ "rules": { "todos" : { "$uid": { ".read": true, // 変更 // 後略 } } } }
recentUpdatedTodosのルール
/recentUpdatedTodos
に最近更新されたタスクを保存するので、設定を追加します。
database.rules.json
{ "rules": { // 中略 "recentUpdatedTodos": { // 追加 ".read": true, ".write": false // #1 }, "$other": { ".validate": false } } }
recentUpdatedTodos
には、Cloud Functionsからのみ書き込むので、書き込み権限はfalse
になっています。
データベースルールのFirebaseへの反映
ファイルを保存して、ルールをFirebaseに反映します。
$ firebase deploy --only database === Deploying to 'todo-sample-xxxxx’… i deploying database i database: checking rules syntax... ✔ database: rules syntax for database todo-sample-xxxxx is valid i database: releasing rules... ✔ database: rules for database todo-sample-xxxxx released successfully ✔ Deploy complete! Project Console: https://console.firebase.google.com/project/todo-sample-xxxxx/overview
反映されました。
★次回の記事
★目次