Reputation: 1425
I have read about the importance of .indexOn
rule for both performance and pricing (reducing the total of downloaded bytes) and I'm wondering what is the correct way to implement it.
In my case, I have a firebase realtime database at this path Cosmetics/Outfits
, so I should declare the rule like this:
"Cosmetics": {
"Outfits": {
".indexOn": ["rarity"]
}}
or like this:
"Outfits": {
".indexOn": ["rarity"]
}
In both cases, I didn't get any errors.
Upvotes: 1
Views: 631
Reputation: 138824
Assuming that your database schema looks like this:
Firebase-root
|
--- Cosmetics
|
--- Outfits
|
--- outfitIdOne
| |
| --- rarity: "rare"
|
--- outfitIdTwo
|
--- rarity: "rare"
So every Outfit
object exist under the Outfits
node, the rules should look like this:
{
"rules": {
"Cosmetics": {
"Outfits": {
".indexOn": "rarity"
}
}
}
}
If you don't create the correct index, the server sends all data to the client, place where the filtering takes place. For more information please see the official documentation regarding indexing data.
Upvotes: 2