2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Firebase rules テストしよ

Last updated at Posted at 2019-09-11

概要

Firebase rulesをどうテストするか

FirebaseはAPIサーバーを作る必要もなく、簡単な設定ですぐに、フロントとかアプリの開発を行うことができます。

データーはFirestoreに保存されます。
Screen Shot 2019-09-11 at 21.20.59.png

Firestoreでは、テーブルをコレクションと思えばいいかな?
コレクションを作り、色んな制限を掛けるのが、rulesですが、自分のデータは自分だけが修正可能とか、他のuserが勝手にデーターいじれたり、修正したりするのを防げる様な設定となります。

rulesテスト方法

テスト方法は二つあります。

firestoreのシミュレーター

Screen Shot 2019-09-11 at 21.27.23.png

こちらデーターも自分で設定して、設定した、rulesを通った結果をすぐ、見ることができます。

テストして、問題なければ、すぐ反映もできるし、簡単で楽です。
でも、rulesが多い場合は一々手動でするのに、限界があるので、面倒です。

firebase エミュレーター

rulesのケースが、多い場合はテストケースを全てコードで書いて、
毎回テストを通します。
最初テストケース作るのに時間がかかりますが、後々、rulesが変更されたり、コレクション変わったりする場合はこっちが、安全で楽になると思います。

使用方法はこちらです。
https://github.com/firebase/quickstart-nodejs/tree/master/firestore-emulator/javascript-quickstart

他にテスト方法があるとか、内容がおかしい場合は教えてください!

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?