Description
Operating System
Windows 11
Environment (if applicable)
Version 128.0.6613.115 (Official Build) (64-bit)
Firebase SDK Version
^10.12.2
Firebase SDK Product(s)
Database
Project Tooling
React, typescript, parcel
Detailed Problem Description
I am iterating over a realtime database schema.
According to https://firebase.google.com/docs/database/security/indexing-data
Firebase allows you to do ad-hoc queries on your data using an arbitrary child key. If you know in advance what your indexes will be, you can define them via the .indexOn rule in your Firebase Realtime Database Security Rules to improve query performance.
Indexes are not required for development unless you are using the REST API.
So why am I receiving
Index not defined, add ".indexOn": "pNumber", for path "/things", to the rules
when the getOrderedByNumber callback is executed ?
Note that this also occurs with the emulator attached.
Steps and code to reproduce issue
export function DemoFiltering() {
const rtb = useRTB();
const thingsListRef = ref(rtb, "things");
const orderByNumber = orderByChild("pNumber");
const getOrderedByNumber = useCallback(
async (constraint: QueryConstraint | undefined, info: string) => {
let snapshot: DataSnapshot;
let orderByNumberQuery: Query;
try {
if (constraint) {
orderByNumberQuery = query(thingsListRef, constraint, orderByNumber);
} else {
orderByNumberQuery = query(thingsListRef, orderByNumber);
}
snapshot = await get(orderByNumberQuery);
} catch (reason) {
// `Index not defined, add ".indexOn": "pNumber", for path "/things", to the rules`
}
//.other code