File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,64 @@ val firestore = Firebase.firestore
27
27
val anotherFirestore = Firebase .firestore(Firebase .app(" myApp" ))
28
28
```
29
29
30
+ ### Get a document
31
+
32
+ ** Kotlin**
33
+ ``` kotlin
34
+ firestore.collection(" cities" )
35
+ .document(" LON" )
36
+ .addSnapshotListener { document: DocumentSnapshot ? , error: ->
37
+ if (error != null ) {
38
+ // Handle error
39
+ return @addSnapshotListener
40
+ }
41
+ if (document != null ) {
42
+ // Use document
43
+ }
44
+ }
45
+ ```
46
+
47
+ ** Kotlin + KTX**
48
+ ``` kotlin
49
+ firestore.collection(" cities" )
50
+ .document(" LON" )
51
+ .snapshots()
52
+ .collect { document: DocumentSnapshot ->
53
+ // Use document
54
+ }
55
+ ```
56
+
57
+ ### Query documents
58
+
59
+ ** Kotlin**
60
+ ``` kotlin
61
+ firestore.collection(" cities" )
62
+ .whereEqualTo(" capital" , true )
63
+ .addSnapshotListener { documents: QuerySnapshot ? , error ->
64
+ if (error != null ) {
65
+ // Handle error
66
+ return @addSnapshotListener
67
+ }
68
+ if (documents != null ) {
69
+ for (document in documents) {
70
+ // Use document
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ ** Kotlin + KTX**
77
+ ``` kotlin
78
+ firestore.collection(" cities" )
79
+ .whereEqualTo(" capital" , true )
80
+ .snapshots()
81
+ .collect { documents: QuerySnapshot ->
82
+ for (document in documents) {
83
+ // Use document
84
+ }
85
+ }
86
+ ```
87
+
30
88
### Convert a DocumentSnapshot field to a POJO
31
89
32
90
** Kotlin**
You can’t perform that action at this time.
0 commit comments