Skip to content
This repository was archived by the owner on Apr 4, 2023. It is now read-only.

Commit 4c9f810

Browse files
Merge pull request #946 from larssn/master
feat: Added missing API
2 parents 99820e2 + 4c8630c commit 4c9f810

File tree

5 files changed

+507
-287
lines changed

5 files changed

+507
-287
lines changed

src/app/firestore/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
import * as firebase from "../../firebase";
2+
// import * as firebaseSdk from 'firebase/app';
23

3-
export module firestore {
4-
export class Firestore {
4+
export namespace firestore {
5+
export class Firestore /*implements firebaseSdk.firestore.Firestore*/ {
56
collection(collectionPath: string): firebase.firestore.CollectionReference {
67
return firebase.firestore.collection(collectionPath);
78
}
89

10+
doc(path: string): firebase.firestore.DocumentReference {
11+
return firebase.firestore.docRef(path);
12+
}
13+
914
FieldValue(): firebase.firestore.FieldValue {
1015
return <any>{
1116
type: undefined,
1217
value: undefined,
1318
serverTimestamp: () => "SERVER_TIMESTAMP",
1419
arrayUnion: (fields: Array<any>) => new firebase.firestore.FieldValue("ARRAY_UNION", fields),
1520
arrayRemove: (fields: Array<any>) => new firebase.firestore.FieldValue("ARRAY_REMOVE", fields)
16-
}
21+
};
1722
}
1823

1924
GeoPoint(latitude: number, longitude: number): firebase.firestore.GeoPoint {

src/firebase-common.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ import * as mlkit from "./mlkit";
88

99
// note that this implementation is overridden for iOS
1010
export class FieldValue {
11-
constructor(public type: firestore.FieldValueType, public value: any) {
12-
};
11+
constructor(
12+
public type: firestore.FieldValueType,
13+
public value: any,
14+
) { }
1315

1416
static serverTimestamp = () => "SERVER_TIMESTAMP";
1517
static arrayUnion = (fields: Array<any>) => new FieldValue("ARRAY_UNION", fields);
@@ -204,19 +206,16 @@ export const firebase: any = {
204206
export abstract class DocumentSnapshot implements firestore.DocumentSnapshot {
205207
public data: () => firestore.DocumentData;
206208

207-
constructor(public id: string, public exists: boolean, documentData: firestore.DocumentData) {
209+
constructor(
210+
public id: string,
211+
public exists: boolean,
212+
documentData: firestore.DocumentData,
213+
public ref: firestore.DocumentReference,
214+
) {
208215
this.data = () => exists ? documentData : undefined;
209216
}
210217
}
211218

212219
export function isDocumentReference(object: any): object is firestore.DocumentReference {
213220
return object && object.discriminator === "docRef";
214221
}
215-
216-
export class QuerySnapshot implements firestore.QuerySnapshot {
217-
public docSnapshots: firestore.DocumentSnapshot[];
218-
219-
forEach(callback: (result: firestore.DocumentSnapshot) => void, thisArg?: any): void {
220-
this.docSnapshots.map(snapshot => callback(snapshot));
221-
}
222-
}

0 commit comments

Comments
 (0)