firebase / firebase/firebase-js-sdk

Indexes are not required for development unless you are using the REST API. - error using WebSocketConnection class

Open
#8,488 3 comments 0 reactions 0 assignees View on GitHub
api: database bug documentation stack:React
Dominant language
TypeScript
Stars
5.1k
Forks
1k
Avg merge
2d 21h
Merged PRs (30d)
37

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
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.