Skip to content

Commit 3ebb93d

Browse files
committed
chore: update Pipeline execution to accept options for index mode
1 parent 44fde63 commit 3ebb93d

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

packages/cloud_firestore/cloud_firestore_web/lib/cloud_firestore_web.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,11 @@ class FirebaseFirestoreWeb extends FirebaseFirestorePlatform {
303303

304304
final dartPipeline = firestore_interop.Pipeline.getInstance(jsPipeline);
305305
return convertWebExceptions(() async {
306-
final snapshot = await dartPipeline.execute();
306+
String? executeOptions;
307+
if (options != null) {
308+
executeOptions = options['indexMode'] as String;
309+
}
310+
final snapshot = await dartPipeline.execute(executeOptions);
307311

308312
final results = snapshot.results
309313
.map((r) => PipelineResultWeb(this, _delegate, r.jsObject))

packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore.dart

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,9 +1183,14 @@ class Pipeline extends JsObjectWrapper<firestore_interop.PipelineJsImpl> {
11831183
: super.fromJsObject(jsObject);
11841184

11851185
/// Runs this pipeline using the global JS SDK execute function.
1186-
Future<PipelineSnapshot> execute() async {
1186+
Future<PipelineSnapshot> execute(String? executeOptions) async {
1187+
final executeOptionsJs = firestore_interop.PipelineExecuteOptionsJsImpl();
1188+
if (executeOptions != null) {
1189+
executeOptionsJs.indexMode = executeOptions.toJS;
1190+
}
1191+
executeOptionsJs.pipeline = jsObject as JSAny;
11871192
final snapshot =
1188-
await firestore_interop.pipelines.execute(jsObject as JSAny).toDart;
1193+
await firestore_interop.pipelines.execute(executeOptionsJs).toDart;
11891194
return PipelineSnapshot.getInstance(snapshot);
11901195
}
11911196
}

packages/cloud_firestore/cloud_firestore_web/lib/src/interop/firestore_interop.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ external PipelinesJsImpl get pipelines;
348348
/// Pipeline expression API — mirrors the Firebase JS SDK pipelines module.
349349
/// Use these to build expressions for where(), sort(), addFields(), aggregate(), etc.
350350
extension type PipelinesJsImpl._(JSObject _) implements JSObject {
351-
external JSPromise<PipelineSnapshotJsImpl> execute(JSAny pipeline);
351+
external JSPromise<PipelineSnapshotJsImpl> execute(
352+
PipelineExecuteOptionsJsImpl pipeline);
352353

353354
// --- Expression builders ---
354355
external ExpressionJsImpl field(JSString path);
@@ -1186,8 +1187,6 @@ extension type PipelineSourceJsImpl._(JSObject _) implements JSObject {
11861187
/// Pipeline returned by PipelineSource methods; chain stages and call execute().
11871188
/// See: https://firebase.google.com/docs/reference/js/firestore_pipelines.pipeline
11881189
extension type PipelineJsImpl._(JSObject _) implements JSObject {
1189-
external JSPromise<PipelineSnapshotJsImpl> execute(
1190-
[PipelineExecuteOptions? options]);
11911190
external PipelineJsImpl limit(JSNumber limit);
11921191
external PipelineJsImpl offset(JSNumber offset);
11931192
external PipelineJsImpl where(JSAny condition);
@@ -1297,3 +1296,12 @@ extension type FindNearestStageOptionsJsImpl._(JSObject _) implements JSObject {
12971296
// ignore: avoid_setters_without_getters
12981297
external set distanceField(JSString value);
12991298
}
1299+
1300+
extension type PipelineExecuteOptionsJsImpl._(JSObject _) implements JSObject {
1301+
PipelineExecuteOptionsJsImpl() : this._(JSObject.new());
1302+
1303+
// ignore: avoid_setters_without_getters
1304+
external set indexMode(JSString value);
1305+
// ignore: avoid_setters_without_getters
1306+
external set pipeline(JSAny value);
1307+
}

0 commit comments

Comments
 (0)