Reputation: 569
I have a Node.js Firestore query that I'm calling .onSnapshot
on and it's returning an empty result:
const query = firebase.firestore()
.collection("stuff")
.orderBy("created_at", "desc")
.where("owner_id", "==", id)
.onSnapshot(
{ includeMetadataChanges: false },
(querySnap: QuerySnap) => {
subs.next(querySnap.docs)
},
(error: Error) => subs.error(error),
() => subs.complete()
);
created_at
is a timestamp and owner_id
is a string for each document; and I can confirm that both exist and aren't null
for any of the entries.Is there something wrong with how I'm using .orderBy
here, or what are some other causes for this issue?
Thanks a lot for any help!
Upvotes: 1
Views: 420
Reputation: 569
I figured it out! Turns out I didn't have the indexing set up in the Firebase console. I've used it before with Realtime Database but didn't realize you needed them with Firestore as well.
Upvotes: 3