Midhilaj
Midhilaj

Reputation: 4997

When i add orderBy app is not working in firestore

Uncaught Error in onSnapshot: Error: The query requires an index. You can create it here at new FirestoreError (index.cjs.js:352) at JsonProtoSerializer.push../node_modules/@firebase/firestore/dist/index.cjs.js.JsonProtoSerializer.fromRpcStatus (index.cjs.js:5862) at JsonProtoSerializer.push../node_modules/@firebase/firestore/dist/index.cjs.js.JsonProtoSerializer.fromWatchChange (index.cjs.js:6359) at PersistentListenStream.push../node_modules/@firebase/firestore/dist/index.cjs.js.PersistentListenStream.onMessage (index.cjs.js:14974) at index.cjs.js:14903 at index.cjs.js:14943 at index.cjs.js:7656 at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:388) at Object.onInvoke (core.js:13851) at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (zone.js:387)



My code

this.firestore.collection('mycollection').ref
        .orderBy("created","desc")
        .where("field","==",true) 
    <br>

but when i remove orderby app work fine

this.firestore.collection('mycollection').ref 
        .where("field","==",true) 

Upvotes: 0

Views: 211

Answers (1)

Quentin C
Quentin C

Reputation: 1893

The error shall contain a link on which you can click to create the said index. You just have to click on it and wait.

Upvotes: 1

Related Questions