File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed
packages/cloud_firestore/cloud_firestore Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 33// BSD-style license that can be found in the LICENSE file.
44
55import 'dart:async' ;
6+ import 'dart:convert' ;
67
78import 'package:flutter/foundation.dart' ;
89import 'package:flutter_test/flutter_test.dart' ;
@@ -229,6 +230,30 @@ void runInstanceTests() {
229230 fieldOverrides: [fieldOverride1, fieldOverride2],
230231 );
231232 });
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+ });
232257 },
233258 );
234259}
Original file line number Diff line number Diff line change @@ -323,6 +323,20 @@ class FirebaseFirestore extends FirebasePluginPlatform {
323323 return _delegate.setIndexConfiguration (json);
324324 }
325325
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+
326340 @override
327341 // ignore: avoid_equals_and_hash_code_on_mutable_classes
328342 bool operator == (Object other) =>
You can’t perform that action at this time.
0 commit comments