File tree 2 files changed +39
-0
lines changed
packages/cloud_firestore/cloud_firestore
2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
5
import 'dart:async' ;
6
+ import 'dart:convert' ;
6
7
7
8
import 'package:flutter/foundation.dart' ;
8
9
import 'package:flutter_test/flutter_test.dart' ;
@@ -229,6 +230,30 @@ void runInstanceTests() {
229
230
fieldOverrides: [fieldOverride1, fieldOverride2],
230
231
);
231
232
});
233
+
234
+ test ('setIndexConfigurationFromJSON()' , () async {
235
+ final json = jsonEncode ({
236
+ 'indexes' : [
237
+ {
238
+ 'collectionGroup' : 'posts' ,
239
+ 'queryScope' : 'COLLECTION' ,
240
+ 'fields' : [
241
+ {'fieldPath' : 'author' , 'arrayConfig' : 'CONTAINS' },
242
+ {'fieldPath' : 'timestamp' , 'order' : 'DESCENDING' }
243
+ ]
244
+ }
245
+ ],
246
+ 'fieldOverrides' : [
247
+ {
248
+ 'collectionGroup' : 'posts' ,
249
+ 'fieldPath' : 'myBigMapField' ,
250
+ 'indexes' : []
251
+ }
252
+ ]
253
+ });
254
+
255
+ await firestore.setIndexConfigurationFromJSON (json);
256
+ });
232
257
},
233
258
);
234
259
}
Original file line number Diff line number Diff line change @@ -323,6 +323,20 @@ class FirebaseFirestore extends FirebasePluginPlatform {
323
323
return _delegate.setIndexConfiguration (json);
324
324
}
325
325
326
+ /// Configures indexing for local query execution. Any previous index configuration is overridden.
327
+ ///
328
+ /// The index entries themselves are created asynchronously. You can continue to use queries that
329
+ /// require indexing even if the indices are not yet available. Query execution will automatically
330
+ /// start using the index once the index entries have been written.
331
+ /// See Firebase documentation to learn how to configure your index configuration JSON file:
332
+ /// https://firebase.google.com/docs/reference/firestore/indexes
333
+ ///
334
+ /// This API is in preview mode and is subject to change.
335
+ @experimental
336
+ Future <void > setIndexConfigurationFromJSON (String json) async {
337
+ return _delegate.setIndexConfiguration (json);
338
+ }
339
+
326
340
@override
327
341
// ignore: avoid_equals_and_hash_code_on_mutable_classes
328
342
bool operator == (Object other) =>
You can’t perform that action at this time.
0 commit comments