Skip to content

Commit 7c19bcc

Browse files
committed
Adding Count to be accessible to the console.
1 parent de32c24 commit 7c19bcc

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

packages/firestore-compat/src/index.console.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,15 @@
1717

1818
import { FirebaseAuthInternalName } from '@firebase/auth-interop-types';
1919
import { Provider } from '@firebase/component';
20+
import { Compat } from '@firebase/util';
2021
import {
2122
_DatabaseId,
2223
Firestore as FirestoreExp,
2324
FirestoreError,
2425
_EmptyAuthCredentialsProvider,
25-
_EmptyAppCheckTokenProvider
26+
_EmptyAppCheckTokenProvider,
27+
Query as ExpQuery,
28+
getCountFromServer
2629
} from '@firebase/firestore';
2730

2831
import {
@@ -98,6 +101,17 @@ export class Firestore extends FirestoreCompat {
98101
new MemoryPersistenceProvider()
99102
);
100103
}
104+
105+
INTERNAL = {
106+
delete: () => this.terminate(),
107+
count: (query: Compat<ExpQuery<unknown>>) => {
108+
return getCountFromServer(query._delegate)
109+
.then(response => {
110+
return response.data().count;
111+
})
112+
.catch(error => Promise.reject(error));
113+
}
114+
};
101115
}
102116

103117
function databaseIdFromFirestoreDatabase(

0 commit comments

Comments
 (0)