Skip to content

Commit 6014f1a

Browse files
committed
fix(firestore): Indices and better error handling
1 parent 83d7e1b commit 6014f1a

File tree

2 files changed

+11
-17
lines changed

2 files changed

+11
-17
lines changed

firestore.indexes.json

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"queryScope": "COLLECTION",
4242
"fields": [
4343
{
44-
"fieldPath": "visibility",
44+
"fieldPath": "uid",
4545
"order": "ASCENDING"
4646
},
4747
{
@@ -59,8 +59,8 @@
5959
"order": "ASCENDING"
6060
},
6161
{
62-
"fieldPath": "uid",
63-
"order": "ASCENDING"
62+
"fieldPath": "likes",
63+
"order": "DESCENDING"
6464
}
6565
]
6666
},
@@ -75,23 +75,23 @@
7575
{
7676
"fieldPath": "uid",
7777
"order": "ASCENDING"
78-
},
79-
{
80-
"fieldPath": "likes",
81-
"order": "DESCENDING"
8278
}
8379
]
8480
},
8581
{
8682
"collectionGroup": "sets",
8783
"queryScope": "COLLECTION",
8884
"fields": [
85+
{
86+
"fieldPath": "visibility",
87+
"order": "ASCENDING"
88+
},
8989
{
9090
"fieldPath": "uid",
9191
"order": "ASCENDING"
9292
},
9393
{
94-
"fieldPath": "creationTime",
94+
"fieldPath": "likes",
9595
"order": "DESCENDING"
9696
}
9797
]
@@ -129,12 +129,6 @@
129129
"ttl": false,
130130
"indexes": []
131131
},
132-
{
133-
"collectionGroup": "sets",
134-
"fieldPath": "name",
135-
"ttl": false,
136-
"indexes": []
137-
},
138132
{
139133
"collectionGroup": "sets",
140134
"fieldPath": "description",

src/js/firebase-rest-api/firestore.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ export const Firestore = {
6666
headers: getRequestHeaders(idToken),
6767
body: JSON.stringify({ structuredQuery })
6868
});
69-
const json: {document: FirestoreRestDocument, done: boolean, }[] & FirestoreRestError = await res.json();
70-
if ("error" in json && json.error) throwResponseError(json.error);
71-
if (json.length === 1 && json[0].done && !json[0].document) return [];
69+
const json: ({document: FirestoreRestDocument, done: boolean } & FirestoreRestError)[] = await res.json();
70+
if ("error" in json[0] && json[0].error) throwResponseError(json[0].error);
71+
if (json.length === 1 && !json[0].document) return [];
7272
return json.map((info) => {
7373
const docObj: ParsedRestDocument = {
7474
pathParts: info.document.name.split("/"),

0 commit comments

Comments
 (0)