@edgedev/firebase 2.1.45 → 2.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/edgeFirebase.ts +18 -1
- package/package.json +1 -1
package/edgeFirebase.ts
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
arrayRemove,
|
|
26
26
|
arrayUnion,
|
|
27
27
|
connectFirestoreEmulator,
|
|
28
|
+
getCountFromServer,
|
|
28
29
|
} from "firebase/firestore";
|
|
29
30
|
|
|
30
31
|
import {
|
|
@@ -60,6 +61,7 @@ import { getStorage, ref, uploadBytesResumable, getDownloadURL, connectStorageEm
|
|
|
60
61
|
import { getFunctions, httpsCallable, connectFunctionsEmulator } from "firebase/functions";
|
|
61
62
|
|
|
62
63
|
import { getAnalytics, logEvent } from "firebase/analytics";
|
|
64
|
+
import { get } from "http";
|
|
63
65
|
|
|
64
66
|
interface FirestoreQuery {
|
|
65
67
|
field: string;
|
|
@@ -1285,9 +1287,22 @@ export const EdgeFirebase = class {
|
|
|
1285
1287
|
return { data, next: nextLast };
|
|
1286
1288
|
};
|
|
1287
1289
|
|
|
1290
|
+
private getTotalCount = async (
|
|
1291
|
+
collectionPath: string,
|
|
1292
|
+
queryList: FirestoreQuery[] = []
|
|
1293
|
+
): Promise<number> => {
|
|
1294
|
+
console.log('getTotalCount')
|
|
1295
|
+
console.log(collectionPath )
|
|
1296
|
+
console.log(queryList)
|
|
1297
|
+
const q = this.getQuery(collectionPath, queryList);
|
|
1298
|
+
const snapshot = await getCountFromServer(q);
|
|
1299
|
+
return snapshot.data().count;
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1288
1302
|
get SearchStaticData() {
|
|
1289
1303
|
const getStaticData = this.getStaticData;
|
|
1290
1304
|
const permissionCheckOnly = this.permissionCheckOnly;
|
|
1305
|
+
const getTotalCount = this.getTotalCount;
|
|
1291
1306
|
const sendResponse = this.sendResponse;
|
|
1292
1307
|
return class {
|
|
1293
1308
|
private collectionPath = "";
|
|
@@ -1300,7 +1315,8 @@ export const EdgeFirebase = class {
|
|
|
1300
1315
|
pagination: [],
|
|
1301
1316
|
staticIsLastPage: true,
|
|
1302
1317
|
staticIsFirstPage: true,
|
|
1303
|
-
staticCurrentPage: ""
|
|
1318
|
+
staticCurrentPage: "",
|
|
1319
|
+
total: 0
|
|
1304
1320
|
});
|
|
1305
1321
|
|
|
1306
1322
|
public prev = async (): Promise<void> => {
|
|
@@ -1408,6 +1424,7 @@ export const EdgeFirebase = class {
|
|
|
1408
1424
|
orderList,
|
|
1409
1425
|
max
|
|
1410
1426
|
);
|
|
1427
|
+
this.results.total = await getTotalCount(this.collectionPath, this.queryList);
|
|
1411
1428
|
if (Object.keys(results.data).length > 0) {
|
|
1412
1429
|
this.results.staticIsLastPage = false;
|
|
1413
1430
|
this.results.data = results.data;
|