Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3c23650
initial
creativecreatorormaybenot Oct 22, 2019
df77698
format
creativecreatorormaybenot Oct 22, 2019
c2d8386
Update gradle.properties
creativecreatorormaybenot Oct 23, 2019
a4aaa69
Merge branch 'master' into firestore-field-path
creativecreatorormaybenot Oct 23, 2019
0549029
resolve conflicts
creativecreatorormaybenot Oct 23, 2019
30e24d5
codec implementation
creativecreatorormaybenot Oct 23, 2019
52910ef
java implementation, tests
creativecreatorormaybenot Oct 23, 2019
77a7fe9
Merge branch 'firestore-field-path' of github.com:creativecreatororma…
creativecreatorormaybenot Oct 23, 2019
97d41a9
revert java formatting
creativecreatorormaybenot Oct 23, 2019
20196b2
revert java formatting
creativecreatorormaybenot Oct 23, 2019
ce25aa0
java implementation
creativecreatorormaybenot Oct 23, 2019
0ab69f3
exception
creativecreatorormaybenot Oct 23, 2019
0f1142d
pre format
creativecreatorormaybenot Oct 23, 2019
88f60cc
assertions
creativecreatorormaybenot Oct 23, 2019
af85c95
Fix tests, add exceptions for debugging help
creativecreatorormaybenot Oct 23, 2019
0a61fcc
fix tests
creativecreatorormaybenot Oct 23, 2019
f28d4d6
iOS implementation
creativecreatorormaybenot Oct 23, 2019
ac9a0d2
format
creativecreatorormaybenot Oct 23, 2019
595b92a
exceptions
creativecreatorormaybenot Oct 23, 2019
0ca445e
format
creativecreatorormaybenot Oct 23, 2019
48dd4ad
remove gradle properties
creativecreatorormaybenot Oct 23, 2019
01818df
remove example gradle properties
creativecreatorormaybenot Oct 23, 2019
8fd37e7
remove gradle collisions
creativecreatorormaybenot Oct 23, 2019
2e3dbf5
i meant to say resolve
creativecreatorormaybenot Oct 23, 2019
4d9ff62
format
creativecreatorormaybenot Oct 23, 2019
61719d5
fix iOS
creativecreatorormaybenot Oct 23, 2019
6073c9c
Update CloudFirestorePlugin.m
creativecreatorormaybenot Oct 24, 2019
fec2965
typo
creativecreatorormaybenot Oct 30, 2019
22edeb7
Merge branch 'firestore-field-path' of github.com:creativecreatororma…
creativecreatorormaybenot Oct 30, 2019
9eade1d
Merge remote-tracking branch 'origin/master' into firestore-field-path
collinjackson Nov 7, 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
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.10

* Added `FieldPath` class and `FieldPath.documentId` to refer to the document id in queries.

## 0.12.9+5

* Fixes a crash on Android when running a transaction without an internet connection.
Expand Down
1 change: 1 addition & 0 deletions packages/cloud_firestore/example/android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
org.gradle.jvmargs=-Xmx1536M
android.enableR8=true
Comment thread
creativecreatorormaybenot marked this conversation as resolved.
Outdated
25 changes: 25 additions & 0 deletions packages/cloud_firestore/example/test_driver/cloud_firestore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -294,5 +294,30 @@ void main() {
await doc1.delete();
await doc2.delete();
});

test('FieldPath.documentId', () async {
// Populate the database with two test documents.
final CollectionReference messages = firestore.collection('messages');
final DocumentReference doc = messages.document();
// Use document ID as a unique identifier to ensure that we don't
// collide with other tests running against this database.
final String uniqueId = doc.documentID;
await doc.setData(<String, dynamic>{
'message': 'testing field path',
'created_at': FieldValue.serverTimestamp(),
});

final QuerySnapshot snapshot = await messages
.where(FieldPath.documentId, isEqualTo: uniqueId)
.getDocuments();

await doc.delete();

final List<DocumentSnapshot> results = snapshot.documents;
final DocumentSnapshot result = results[0];

expect(results.length, 1);
expect(result.data['message'], 'testing field path');
});
});
}
1 change: 1 addition & 0 deletions packages/cloud_firestore/lib/cloud_firestore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ part 'src/collection_reference.dart';
part 'src/document_change.dart';
part 'src/document_reference.dart';
part 'src/document_snapshot.dart';
part 'src/field_path.dart';
part 'src/field_value.dart';
part 'src/firestore.dart';
part 'src/firestore_message_codec.dart';
Expand Down
11 changes: 11 additions & 0 deletions packages/cloud_firestore/lib/src/field_path.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright 2017, the Chromium project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

part of cloud_firestore;

/// A [FieldPath] refers to a field in a document.
class FieldPath {
/// The path to the document id, which can be used in queries.
static String get documentId => '__name__';
Comment thread
collinjackson marked this conversation as resolved.
Outdated
}
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 <flutter-dev@googlegroups.com>
homepage: https://github.com/FirebaseExtended/flutterfire/tree/master/packages/cloud_firestore
version: 0.12.9+5
version: 0.12.10

flutter:
plugin:
Expand Down
26 changes: 26 additions & 0 deletions packages/cloud_firestore/test/cloud_firestore_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,32 @@ void main() {
),
);
});

test('FieldPath', () async {
await collectionReference
.where(FieldPath.documentId, isEqualTo: 'bar')
.getDocuments();
expect(
log,
equals(<Matcher>[
isMethodCall(
'Query#getDocuments',
arguments: <String, dynamic>{
'app': app.name,
'path': 'foo',
'isCollectionGroup': false,
'parameters': <String, dynamic>{
'where': <List<dynamic>>[
<dynamic>['__name__', '==', 'bar'],
],
'orderBy': <List<dynamic>>[],
},
'source': 'default',
},
),
]),
);
});
});

group('FirestoreMessageCodec', () {
Expand Down