Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6f25896
Migrated linkWithCredential function to user object
awazgyawali May 8, 2019
3f9839f
Fixed test
awazgyawali May 8, 2019
98917f5
added change log and increased version of the plugin
awazgyawali May 8, 2019
4a106f7
Minor fixes
awazgyawali May 8, 2019
a77e8f5
Added collection group query
awazgyawali May 21, 2019
d509a55
Added an assertion
awazgyawali May 21, 2019
e811d07
Formatted files
awazgyawali May 21, 2019
77ceefe
Removed keys
awazgyawali May 21, 2019
66124e5
Merged with master
awazgyawali May 21, 2019
5655c88
Minor changes
awazgyawali May 21, 2019
677c3f7
Completed on IOS too
awazgyawali May 22, 2019
2649b9f
Making google formatter happy
awazgyawali May 22, 2019
3cbc15e
Added changelog and bumped version
awazgyawali May 22, 2019
29fad5e
Changed BOOL casting to NSNumber casting
awazgyawali May 22, 2019
93f4ac7
decapitalized collection word
awazgyawali May 22, 2019
06c18e4
Changrd bool variable name
awazgyawali May 22, 2019
8d691e2
Added newer field value to the test
awazgyawali May 22, 2019
54c4b0f
Added some test for collection group query
awazgyawali May 22, 2019
10f11b0
Changed name od the tests
awazgyawali May 22, 2019
4da92b2
Formatted test file
awazgyawali May 22, 2019
5630fe4
Fixed test fail case
awazgyawali May 23, 2019
6721d26
Added som test(UNtested)
awazgyawali May 23, 2019
6dad41d
Merge branch 'master' into group_collection_query
awazgyawali May 27, 2019
5d87484
Merge remote-tracking branch 'origin/master' into group_collection_query
collinjackson Jun 4, 2019
930a47f
Fix test
collinjackson Jun 4, 2019
a1ced47
Merge remote-tracking branch 'origin/master' into group_collection_query
collinjackson Jun 4, 2019
ab271f8
Fix tests
collinjackson Jun 4, 2019
8d87d51
Fix merge damage
collinjackson Jun 4, 2019
0c964da
Ensure that CocoaPods on Cirrus is always the latest version.
collinjackson Jun 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ task:
SIMCTL_CHILD_MAPS_API_KEY: ENCRYPTED[596a9f6bca436694625ac50851dc5da6b4d34cba8025f7db5bc9465142e8cd44e15f69e3507787753accebfc4910d550]
setup_script:
- brew update
- brew upgrade cocoapods
- brew install libimobiledevice
- brew install ideviceinstaller
- brew install ios-deploy
Expand Down
4 changes: 4 additions & 0 deletions packages/cloud_firestore/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.12.3

* Added support for `Query.collectionGroup`.

## 0.12.2

* Ensure that all channel calls to the Dart side from the Java side are done
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ private FirebaseFirestore getFirestore(Map<String, Object> arguments) {
return FirebaseFirestore.getInstance(FirebaseApp.getInstance(appName));
}

private Query getReference(Map<String, Object> arguments) {
if ((boolean) arguments.get("isCollectionGroup")) return getCollectionGroupReference(arguments);
else return getCollectionReference(arguments);
}

private Query getCollectionGroupReference(Map<String, Object> arguments) {
String path = (String) arguments.get("path");
return getFirestore(arguments).collectionGroup(path);
}

private CollectionReference getCollectionReference(Map<String, Object> arguments) {
String path = (String) arguments.get("path");
return getFirestore(arguments).collection(path);
Expand Down Expand Up @@ -180,7 +190,7 @@ private Transaction getTransaction(Map<String, Object> arguments) {
}

private Query getQuery(Map<String, Object> arguments) {
Query query = getCollectionReference(arguments);
Query query = getReference(arguments);
@SuppressWarnings("unchecked")
Map<String, Object> parameters = (Map<String, Object>) arguments.get("parameters");
if (parameters == null) return query;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class FlutterFirebaseAppRegistrar implements ComponentRegistrar {
private static final String LIBRARY_NAME = "flutter-fire-fst";
private static final String LIBRARY_VERSION = "0.12.2";
private static final String LIBRARY_VERSION = "0.12.3";

@Override
public List<Component<?>> getComponents() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() {
firestore = Firestore(app: app);
});

test('getDocuments', () async {
test('getDocumentsFromCollection', () async {
final Query query = firestore
.collection('messages')
.where('message', isEqualTo: 'Hello world!')
Expand All @@ -43,6 +43,21 @@ void main() {
expect(snapshot.data['message'], 'Hello world!');
});

test('getDocumentsFromCollectionGroup', () async {
final Query query = firestore
.collectionGroup('reviews')
.where('message', isEqualTo: 'Hello world!')
.limit(1);
final QuerySnapshot querySnapshot = await query.getDocuments();
expect(querySnapshot.documents.first['message'], 'Hello world!');
final DocumentReference firstDoc =
querySnapshot.documents.first.reference;
final DocumentSnapshot documentSnapshot = await firstDoc.get();
expect(documentSnapshot.data['message'], 'Hello world!');
final DocumentSnapshot snapshot = await firstDoc.snapshots().first;
expect(snapshot.data['message'], 'Hello world!');
});

test('increment', () async {
final DocumentReference ref = firestore.collection('messages').document();
await ref.setData(<String, dynamic>{
Expand Down
11 changes: 9 additions & 2 deletions packages/cloud_firestore/ios/Classes/CloudFirestorePlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#import <Firebase/Firebase.h>

#define LIBRARY_NAME @"flutter-firebase_cloud_firestore"
#define LIBRARY_VERSION @"0.12.2"
#define LIBRARY_VERSION @"0.12.3"

static FlutterError *getFlutterError(NSError *error) {
if (error == nil) return nil;
Expand Down Expand Up @@ -42,7 +42,14 @@
}

static FIRQuery *getQuery(NSDictionary *arguments) {
FIRQuery *query = [getFirestore(arguments) collectionWithPath:arguments[@"path"]];
NSNumber *data = arguments[@"isCollectionGroup"];
BOOL isCollectionGroup = data.boolValue;
FIRQuery *query;
if (isCollectionGroup) {
query = [getFirestore(arguments) collectionGroupWithID:arguments[@"path"]];
} else {
query = [getFirestore(arguments) collectionWithPath:arguments[@"path"]];
}
NSDictionary *parameters = arguments[@"parameters"];
NSArray *whereConditions = parameters[@"where"];
for (id item in whereConditions) {
Expand Down
11 changes: 11 additions & 0 deletions packages/cloud_firestore/lib/src/firestore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ class Firestore {
return CollectionReference._(this, path.split('/'));
}

/// Gets a [Query] for the specified collection group.
Query collectionGroup(String path) {
assert(path != null);
assert(!path.contains("/"), "Collection IDs must not contain '/'.");
return Query._(
firestore: this,
isCollectionGroup: true,
pathComponents: path.split('/'),
);
}

/// Gets a [DocumentReference] for the specified Firestore path.
DocumentReference document(String path) {
assert(path != null);
Expand Down
6 changes: 6 additions & 0 deletions packages/cloud_firestore/lib/src/query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class Query {
Query._(
{@required this.firestore,
@required List<String> pathComponents,
bool isCollectionGroup = false,
Map<String, dynamic> parameters})
: _pathComponents = pathComponents,
_isCollectionGroup = isCollectionGroup,
_parameters = parameters ??
Map<String, dynamic>.unmodifiable(<String, dynamic>{
'where': List<List<dynamic>>.unmodifiable(<List<dynamic>>[]),
Expand All @@ -24,12 +26,14 @@ class Query {

final List<String> _pathComponents;
final Map<String, dynamic> _parameters;
final bool _isCollectionGroup;

String get _path => _pathComponents.join('/');

Query _copyWithParameters(Map<String, dynamic> parameters) {
return Query._(
firestore: firestore,
isCollectionGroup: _isCollectionGroup,
pathComponents: _pathComponents,
parameters: Map<String, dynamic>.unmodifiable(
Map<String, dynamic>.from(_parameters)..addAll(parameters),
Expand Down Expand Up @@ -58,6 +62,7 @@ class Query {
<String, dynamic>{
'app': firestore.app.name,
'path': _path,
'isCollectionGroup': _isCollectionGroup,
'parameters': _parameters,
},
).then<int>((dynamic result) => result);
Expand Down Expand Up @@ -88,6 +93,7 @@ class Query {
<String, dynamic>{
'app': firestore.app.name,
'path': _path,
'isCollectionGroup': _isCollectionGroup,
'parameters': _parameters,
'source': _getSourceString(source),
},
Expand Down
2 changes: 1 addition & 1 deletion packages/cloud_firestore/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for Cloud Firestore, a cloud-hosted, noSQL database
live synchronization and offline support on Android and iOS.
author: Flutter Team <[email protected]>
homepage: https://github.com/flutter/plugins/tree/master/packages/cloud_firestore
version: 0.12.2
version: 0.12.3

flutter:
plugin:
Expand Down
Loading