firebase-tools
firebase-tools copied to clipboard
database emulator seems not support "indexOn" rule setting.
Describe the bug Using realtime database with localhost emulator.
To Reproduce
- setting rules as follow:
{
"rules": {
".read": "now < 1656777600000", // 2022-7-3
".write": "now < 1656777600000", // 2022-7-3
"training": {
"groups": {
".indexOn": ["groupName"]
}
}
}
}
- start firebase emulator:
firebase emulators:start --only auth,database
- insert some sample data:
{
"training": {
"groups": {
"-N3mtNIVU7HCKcCnPGN5": {
"groupName": "chest",
"trainName": "dumbell incline chest press"
},
"-N3mtQu8tRutEIlzQBo8": {
"groupName": "chest",
"trainName": "dumbell literal chest press"
},
"-N3mtRBPMRW6WwZYuP0m": {
"groupName": "chest",
"trainName": "dumbell decline chest press"
}
}
}
}
- Try to search data by "groupName" (using clojureScript with
shadow-cljs
, firebase sdk version9.8.1
)
(defn get-chest-test
[]
(let [db (ref (get-database) "/training/groups")]
(-> (query db (orderByChild "groupName") (equalTo "chest")))))
(-> (get-chest-test)
(database/get)
(.then #(do (js/console.log (.val %))))
(.catch #(js/console.log %)))
- see the error in console (test in firefox, version
101.0
)
Error: Index not defined, add ".indexOn": "groupName", for path "/training/groups", to the rules
connect to production works prefect without error.
Expected behavior
{
"-N3mvAtQ0Q5ZUzDo-Jeg": {
"groupName": "chest",
"trainName": "dumbell incline chest press"
},
"-N3mvAteWJdlOeqA9UIY": {
"groupName": "chest",
"trainName": "dumbell literal chest press"
},
"-N3mvAtqBwEKMjja-xCD": {
"groupName": "chest",
"trainName": "dumbell decline chest press"
}
}
Desktop (please complete the following information):
- OS: Mac Monterey 12.2.1
- Browser firefox
- Version 101