Skip to content

Commit 8eb9082

Browse files
committed
Cast Firestore
1 parent 682997d commit 8eb9082

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

packages/firestore/src/api/pipeline.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Stage } from '../lite-api/stage';
66
import { UserDataReader } from '../lite-api/user_data_reader';
77
import { AbstractUserDataWriter } from '../lite-api/user_data_writer';
88
import { DocumentKey } from '../model/document_key';
9+
import { cast } from '../util/input_validation';
910

1011
import { ensureFirestoreConfigured, Firestore } from './database';
1112

@@ -23,7 +24,7 @@ export class Pipeline<
2324
* @param converter
2425
*/
2526
constructor(
26-
private db: Firestore,
27+
db: Firestore,
2728
userDataReader: UserDataReader,
2829
userDataWriter: AbstractUserDataWriter,
2930
documentReferenceFactory: (id: DocumentKey) => DocumentReference,
@@ -74,7 +75,8 @@ export class Pipeline<
7475
* @return A Promise representing the asynchronous pipeline execution.
7576
*/
7677
execute(): Promise<Array<PipelineResult<AppModelType>>> {
77-
const client = ensureFirestoreConfigured(this.db);
78+
const firestore = cast(this._db, Firestore);
79+
const client = ensureFirestoreConfigured(firestore);
7880
return firestoreClientExecutePipeline(client, this).then(result => {
7981
const docs = result.map(
8082
element =>

packages/firestore/src/lite-api/pipeline.ts

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,19 @@ export class Pipeline<AppModelType = DocumentData>
124124
/**
125125
* @internal
126126
* @private
127-
* @param liteDb
127+
* @param _db
128128
* @param userDataReader
129129
* @param userDataWriter
130130
* @param documentReferenceFactory
131131
* @param stages
132132
* @param converter
133133
*/
134134
constructor(
135-
private liteDb: Firestore,
135+
/**
136+
* @internal
137+
* @private
138+
*/
139+
public _db: Firestore,
136140
private userDataReader: UserDataReader,
137141
/**
138142
* @internal
@@ -184,7 +188,7 @@ export class Pipeline<AppModelType = DocumentData>
184188
)
185189
);
186190
return new Pipeline(
187-
this.liteDb,
191+
this._db,
188192
this.userDataReader,
189193
this.userDataWriter,
190194
this.documentReferenceFactory,
@@ -230,7 +234,7 @@ export class Pipeline<AppModelType = DocumentData>
230234
projections = this.readUserData('select', projections);
231235
copy.push(new Select(projections));
232236
return new Pipeline(
233-
this.liteDb,
237+
this._db,
234238
this.userDataReader,
235239
this.userDataWriter,
236240
this.documentReferenceFactory,
@@ -322,7 +326,7 @@ export class Pipeline<AppModelType = DocumentData>
322326
this.readUserData('where', condition);
323327
copy.push(new Where(condition));
324328
return new Pipeline(
325-
this.liteDb,
329+
this._db,
326330
this.userDataReader,
327331
this.userDataWriter,
328332
this.documentReferenceFactory,
@@ -355,7 +359,7 @@ export class Pipeline<AppModelType = DocumentData>
355359
const copy = this.stages.map(s => s);
356360
copy.push(new Offset(offset));
357361
return new Pipeline(
358-
this.liteDb,
362+
this._db,
359363
this.userDataReader,
360364
this.userDataWriter,
361365
this.documentReferenceFactory,
@@ -393,7 +397,7 @@ export class Pipeline<AppModelType = DocumentData>
393397
const copy = this.stages.map(s => s);
394398
copy.push(new Limit(limit));
395399
return new Pipeline(
396-
this.liteDb,
400+
this._db,
397401
this.userDataReader,
398402
this.userDataWriter,
399403
this.documentReferenceFactory,
@@ -438,7 +442,7 @@ export class Pipeline<AppModelType = DocumentData>
438442
)
439443
);
440444
return new Pipeline(
441-
this.liteDb,
445+
this._db,
442446
this.userDataReader,
443447
this.userDataWriter,
444448
this.documentReferenceFactory,
@@ -551,7 +555,7 @@ export class Pipeline<AppModelType = DocumentData>
551555
);
552556
}
553557
return new Pipeline(
554-
this.liteDb,
558+
this._db,
555559
this.userDataReader,
556560
this.userDataWriter,
557561
this.documentReferenceFactory,
@@ -579,7 +583,7 @@ export class Pipeline<AppModelType = DocumentData>
579583
)
580584
);
581585
return new Pipeline(
582-
this.liteDb,
586+
this._db,
583587
this.userDataReader,
584588
this.userDataWriter,
585589
this.documentReferenceFactory,
@@ -640,7 +644,7 @@ export class Pipeline<AppModelType = DocumentData>
640644
}
641645

642646
return new Pipeline(
643-
this.liteDb,
647+
this._db,
644648
this.userDataReader,
645649
this.userDataWriter,
646650
this.documentReferenceFactory,
@@ -678,7 +682,7 @@ export class Pipeline<AppModelType = DocumentData>
678682
});
679683
copy.push(new GenericStage(name, params));
680684
return new Pipeline(
681-
this.liteDb,
685+
this._db,
682686
this.userDataReader,
683687
this.userDataWriter,
684688
this.documentReferenceFactory,
@@ -785,7 +789,7 @@ export class Pipeline<AppModelType = DocumentData>
785789
* @return A Promise representing the asynchronous pipeline execution.
786790
*/
787791
execute(): Promise<Array<PipelineResult<AppModelType>>> {
788-
const datastore = getDatastore(this.liteDb);
792+
const datastore = getDatastore(this._db);
789793
return invokeExecutePipeline(datastore, this).then(result => {
790794
const docs = result
791795
// Currently ignore any response from ExecutePipeline that does

0 commit comments

Comments
 (0)